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
cfbf6aa9
Commit
cfbf6aa9
authored
Nov 19, 2018
by
Jan Safranek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix unit test to run with random UID
User that runs the tests desn't need to be in /etc/passwd and thus user.Current() can fail. Assume the user is not root in this case.
parent
7ba79c31
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
4 deletions
+12
-4
nsenter_mount_test.go
pkg/util/mount/nsenter_mount_test.go
+12
-4
No files found.
pkg/util/mount/nsenter_mount_test.go
View file @
cfbf6aa9
...
...
@@ -169,11 +169,19 @@ func newFakeNsenterMounter(tmpdir string, t *testing.T) (mounter *NsenterMounter
}
func
TestNsenterExistsFile
(
t
*
testing
.
T
)
{
user
,
err
:=
user
.
Current
()
if
err
!=
nil
{
t
.
Error
(
err
)
var
isRoot
bool
usr
,
err
:=
user
.
Current
()
if
err
==
nil
{
isRoot
=
usr
.
Username
==
"root"
}
else
{
switch
err
.
(
type
)
{
case
user
.
UnknownUserIdError
:
// Root should be always known, this is some random UID
isRoot
=
false
default
:
t
.
Fatal
(
err
)
}
}
isRoot
:=
user
.
Username
==
"root"
tests
:=
[]
struct
{
name
string
...
...
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