From 79bb611c22e39407f5259e106803f46f26b22bf4 Mon Sep 17 00:00:00 2001 From: Tiexin Guo Date: Mon, 23 Sep 2024 09:07:16 +0800 Subject: [PATCH] chore: refactor after review --- internals/cli/cmd_add_test.go | 5 ++--- internals/osutil/io_test.go | 2 +- internals/osutil/stat_test.go | 4 ++-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/internals/cli/cmd_add_test.go b/internals/cli/cmd_add_test.go index 9233dd7c..83db69da 100644 --- a/internals/cli/cmd_add_test.go +++ b/internals/cli/cmd_add_test.go @@ -100,10 +100,9 @@ services: } else if path == triggerLayerPath { c.Assert(err, check.ErrorMatches, "triggered") } else if path == unreadableLayerPath { - if os.Getuid() == 0 { - c.Skip("requires running as non-root users") + if os.Getuid() != 0 { + c.Assert(os.IsPermission(err), check.Equals, true) } - c.Assert(os.IsPermission(err), check.Equals, true) } } diff --git a/internals/osutil/io_test.go b/internals/osutil/io_test.go index b6c00d2a..686a9eb6 100644 --- a/internals/osutil/io_test.go +++ b/internals/osutil/io_test.go @@ -85,7 +85,7 @@ func (ts *AtomicWriteTestSuite) TestAtomicWriteFileSymlinkNoFollow(c *C) { defer os.Chmod(rodir, 0700) if os.Getuid() == 0 { - c.Skip("requires running as non-root users") + c.Skip("requires running as non-root user") } err := osutil.AtomicWriteFile(p, []byte("hi"), 0600, 0) c.Assert(err, NotNil) diff --git a/internals/osutil/stat_test.go b/internals/osutil/stat_test.go index b90dad57..51393e06 100644 --- a/internals/osutil/stat_test.go +++ b/internals/osutil/stat_test.go @@ -110,7 +110,7 @@ func makeTestPathInDir(c *C, dir string, path string, mode os.FileMode) string { func (s *StatTestSuite) TestIsWritableDir(c *C) { if os.Getuid() == 0 { - c.Skip("requires running as non-root users") + c.Skip("requires running as non-root user") } for _, t := range []struct { @@ -185,7 +185,7 @@ func (s *StatTestSuite) TestExistsIsDir(c *C) { } if os.Getuid() == 0 { - c.Skip("requires running as non-root users") + c.Skip("requires running as non-root user") } p := makeTestPath(c, "foo/bar", 0) c.Assert(os.Chmod(filepath.Dir(p), 0), IsNil)