mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 19:31:44 +00:00
Merge pull request #71207 from jsafrane/mount-anyuid-test
Fix unit test to run with random UID
This commit is contained in:
commit
8c5b9b7479
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user