Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
61e359ca
Commit
61e359ca
authored
Dec 27, 2018
by
Michelle Au
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move linux test utils to os-independent test file
parent
f6c5817b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
38 deletions
+39
-38
mount_helper_test.go
pkg/util/mount/mount_helper_test.go
+39
-0
mount_linux_test.go
pkg/util/mount/mount_linux_test.go
+0
-38
No files found.
pkg/util/mount/mount_helper_test.go
View file @
61e359ca
...
...
@@ -17,6 +17,7 @@ limitations under the License.
package
mount
import
(
"fmt"
"io/ioutil"
"os"
"path/filepath"
...
...
@@ -111,3 +112,41 @@ func TestDoUnmountMountPoint(t *testing.T) {
})
}
}
func
validateDirEmpty
(
dir
string
)
error
{
files
,
err
:=
ioutil
.
ReadDir
(
dir
)
if
err
!=
nil
{
return
err
}
if
len
(
files
)
!=
0
{
return
fmt
.
Errorf
(
"Directory %q is not empty"
,
dir
)
}
return
nil
}
func
validateDirExists
(
dir
string
)
error
{
_
,
err
:=
ioutil
.
ReadDir
(
dir
)
if
err
!=
nil
{
return
err
}
return
nil
}
func
validateDirNotExists
(
dir
string
)
error
{
_
,
err
:=
ioutil
.
ReadDir
(
dir
)
if
os
.
IsNotExist
(
err
)
{
return
nil
}
if
err
!=
nil
{
return
err
}
return
fmt
.
Errorf
(
"dir %q still exists"
,
dir
)
}
func
validateFileExists
(
file
string
)
error
{
if
_
,
err
:=
os
.
Stat
(
file
);
err
!=
nil
{
return
err
}
return
nil
}
pkg/util/mount/mount_linux_test.go
View file @
61e359ca
...
...
@@ -666,44 +666,6 @@ func TestSafeMakeDir(t *testing.T) {
}
}
func
validateDirEmpty
(
dir
string
)
error
{
files
,
err
:=
ioutil
.
ReadDir
(
dir
)
if
err
!=
nil
{
return
err
}
if
len
(
files
)
!=
0
{
return
fmt
.
Errorf
(
"Directory %q is not empty"
,
dir
)
}
return
nil
}
func
validateDirExists
(
dir
string
)
error
{
_
,
err
:=
ioutil
.
ReadDir
(
dir
)
if
err
!=
nil
{
return
err
}
return
nil
}
func
validateDirNotExists
(
dir
string
)
error
{
_
,
err
:=
ioutil
.
ReadDir
(
dir
)
if
os
.
IsNotExist
(
err
)
{
return
nil
}
if
err
!=
nil
{
return
err
}
return
fmt
.
Errorf
(
"dir %q still exists"
,
dir
)
}
func
validateFileExists
(
file
string
)
error
{
if
_
,
err
:=
os
.
Stat
(
file
);
err
!=
nil
{
return
err
}
return
nil
}
func
TestRemoveEmptyDirs
(
t
*
testing
.
T
)
{
defaultPerm
:=
os
.
FileMode
(
0750
)
tests
:=
[]
struct
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment