diff --git a/tests/exec.go b/tests/exec.go index 660f508..ced01d6 100644 --- a/tests/exec.go +++ b/tests/exec.go @@ -94,14 +94,15 @@ func Exec(o *option.Option) { for _, user := range []string{"-u", "--user"} { user := user ginkgo.It(fmt.Sprintf("should output user id according to user name specified by %s flag", user), func() { - testCases := map[string]string{ - "1000": "uid=1000 gid=0(root)", - "1000:users": "uid=1000 gid=100(users)", + testCases := map[string][]string{ + "1000": {"uid=1000 gid=0(root)", "uid=1000 gid=0(root) groups=0(root)"}, + "1000:users": {"uid=1000 gid=100(users)", "uid=1000 gid=100(users) groups=100(users)"}, } for name, want := range testCases { output := command.StdoutStr(o, "exec", user, name, testContainerName, "id") - gomega.Expect(output).Should(gomega.Equal(want)) + // TODO: Remove the Or operator after upgrading the nerdctl dependency to 1.2.1 to only match want[1] + gomega.Expect(output).Should(gomega.Or(gomega.Equal(want[0]), gomega.Equal(want[1]))) } }) } diff --git a/tests/images.go b/tests/images.go index 71f1575..302ad0e 100644 --- a/tests/images.go +++ b/tests/images.go @@ -52,7 +52,9 @@ func Images(o *option.Option) { ginkgo.It("should list truncated IMAGE IDs", func() { images := command.StdoutAsLines(o, "images", "--quiet") gomega.Expect(images).ShouldNot(gomega.BeEmpty()) - gomega.Expect(images).Should(gomega.HaveEach(gomega.MatchRegexp(sha256RegexTruncated))) + // TODO: Remove the Or operator after upgrading the nerdctl dependency to 1.2.1 to only match sha256RegexFull + gomega.Expect(images).To(gomega.Or(gomega.HaveEach(gomega.MatchRegexp(sha256RegexFull)), + gomega.HaveEach(gomega.MatchRegexp(sha256RegexTruncated)))) }) ginkgo.It("should list full IMAGE IDs", func() { images := command.StdoutAsLines(o, "images", "--quiet", "--no-trunc") diff --git a/tests/run.go b/tests/run.go index c8f3d5b..2d066d0 100644 --- a/tests/run.go +++ b/tests/run.go @@ -575,34 +575,44 @@ func Run(o *RunOption) { user := user ginkgo.It(fmt.Sprintf("should set the user of a container with %s flag", user), func() { // Ref: https://wiki.gentoo.org/wiki/UID_GID_Assignment_Table - testCases := map[string]string{ - "65534": "uid=65534(nobody) gid=65534(nobody)", - "nobody": "uid=65534(nobody) gid=65534(nobody)", - "nobody:users": "uid=65534(nobody) gid=100(users)", - "nobody:100": "uid=65534(nobody) gid=100(users)", + testCases := map[string][]string{ + "65534": {"uid=65534(nobody) gid=65534(nobody)", "uid=65534(nobody) gid=65534(nobody) groups=65534(nobody)"}, + "nobody": {"uid=65534(nobody) gid=65534(nobody)", "uid=65534(nobody) gid=65534(nobody) groups=65534(nobody)"}, + "nobody:users": {"uid=65534(nobody) gid=100(users)", "uid=65534(nobody) gid=100(users) groups=100(users)"}, + "nobody:100": {"uid=65534(nobody) gid=100(users)", "uid=65534(nobody) gid=100(users) groups=100(users)"}, } for userStr, expected := range testCases { output := command.StdoutStr(o.BaseOpt, "run", user, userStr, defaultImage, "id") - gomega.Expect(output).To(gomega.Equal(expected)) + // TODO: Remove the Or operator after upgrading the nerdctl dependency to 1.2.1 to only match expected[1] + gomega.Expect(output).Should(gomega.Or(gomega.Equal(expected[0]), gomega.Equal(expected[1]))) } }) ginkgo.It("should add additional groups for a specific user with --group-add flag", func() { testCases := []struct { groups []string - expected string + expected []string }{ { - groups: []string{"users"}, - expected: "uid=65534(nobody) gid=65534(nobody) groups=100(users)", + groups: []string{"users"}, + expected: []string{ + "uid=65534(nobody) gid=65534(nobody) groups=100(users)", + "uid=65534(nobody) gid=65534(nobody) groups=100(users),65534(nobody)", + }, }, { - groups: []string{"100"}, - expected: "uid=65534(nobody) gid=65534(nobody) groups=100(users)", + groups: []string{"100"}, + expected: []string{ + "uid=65534(nobody) gid=65534(nobody) groups=100(users)", + "uid=65534(nobody) gid=65534(nobody) groups=100(users),65534(nobody)", + }, }, { - groups: []string{"users", "nogroup"}, - expected: "uid=65534(nobody) gid=65534(nobody) groups=100(users),65533(nogroup)", + groups: []string{"users", "nogroup"}, + expected: []string{ + "uid=65534(nobody) gid=65534(nobody) groups=100(users),65533(nogroup)", + "uid=65534(nobody) gid=65534(nobody) groups=100(users),65533(nogroup),65534(nobody)", + }, }, } @@ -613,7 +623,8 @@ func Run(o *RunOption) { } args = append(args, defaultImage, "id") output := command.StdoutStr(o.BaseOpt, args...) - gomega.Expect(output).To(gomega.Equal(tc.expected)) + // TODO: Remove the Or operator after upgrading the nerdctl dependency to 1.2.1 to only match tc.expected[1] + gomega.Expect(output).Should(gomega.Or(gomega.Equal(tc.expected[0]), gomega.Equal(tc.expected[1]))) } }) }