Unverified Commit 82c8e063 authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #66850 from linyouchong/pr-0801-issue66809

Automatic merge from submit-queue (batch tested with PRs 66850, 66902, 66779, 66864, 66912). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Fix unit test failure: TestNsenterExistsFile **What this PR does / why we need it**: Fix unit test failure: TestNsenterExistsFile **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*: Fixes #66809 **Special notes for your reviewer**: NONE **Release note**: ```release-note NONE ```
parents 23111ad4 708cff1a
......@@ -21,6 +21,7 @@ package mount
import (
"io/ioutil"
"os"
"os/user"
"path/filepath"
"strings"
"testing"
......@@ -168,6 +169,12 @@ func newFakeNsenterMounter(tmpdir string, t *testing.T) (mounter *NsenterMounter
}
func TestNsenterExistsFile(t *testing.T) {
user, err := user.Current()
if err != nil {
t.Error(err)
}
isRoot := user.Username == "root"
tests := []struct {
name string
prepare func(base, rootfs string) (string, error)
......@@ -227,8 +234,8 @@ func TestNsenterExistsFile(t *testing.T) {
return path, nil
},
expectedOutput: false,
expectError: true,
expectedOutput: isRoot, // ExistsPath success when running as root
expectError: !isRoot, // ExistsPath must fail when running as not-root
},
{
name: "relative symlink to existing file",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment