From 003c2c949fd4429c8775185d581cac733c16b859 Mon Sep 17 00:00:00 2001 From: Billy Zha Date: Tue, 29 Aug 2023 05:51:47 +0000 Subject: [PATCH] test(e2e): migrate `oras tag` specs to ZOT Signed-off-by: Billy Zha --- test/e2e/suite/command/tag.go | 48 ++++++++++------------------------- 1 file changed, 13 insertions(+), 35 deletions(-) diff --git a/test/e2e/suite/command/tag.go b/test/e2e/suite/command/tag.go index 2a012acc2..3895d0424 100644 --- a/test/e2e/suite/command/tag.go +++ b/test/e2e/suite/command/tag.go @@ -33,7 +33,7 @@ var _ = Describe("ORAS beginners:", func() { }) It("should fail when provided manifest reference is not found", func() { - ORAS("tag", RegistryRef(Host, ImageRepo, "i-dont-think-this-tag-exists"), "tagged").ExpectFailure().MatchErrKeyWords("Error:").Exec() + ORAS("tag", RegistryRef(ZOTHost, ImageRepo, "i-dont-think-this-tag-exists"), "tagged").ExpectFailure().MatchErrKeyWords("Error:").Exec() }) It("should fail when provided invalid reference", func() { @@ -52,16 +52,16 @@ var _ = Describe("1.1 registry users:", func() { } When("running `tag`", func() { It("should add a tag to an existent manifest when providing tag reference", func() { - tagAndValidate(Host, ImageRepo, multi_arch.Tag, multi_arch.Digest, "tag-via-tag") + tagAndValidate(ZOTHost, ImageRepo, multi_arch.Tag, multi_arch.Digest, "tag-via-tag") }) It("should add a tag to an existent manifest when providing digest reference", func() { - tagAndValidate(Host, ImageRepo, multi_arch.Digest, multi_arch.Digest, "tag-via-digest") + tagAndValidate(ZOTHost, ImageRepo, multi_arch.Digest, multi_arch.Digest, "tag-via-digest") }) It("should add multiple tags to an existent manifest when providing digest reference", func() { - tagAndValidate(Host, ImageRepo, multi_arch.Digest, multi_arch.Digest, "tag1-via-digest", "tag2-via-digest", "tag3-via-digest") + tagAndValidate(ZOTHost, ImageRepo, multi_arch.Digest, multi_arch.Digest, "tag1-via-digest", "tag2-via-digest", "tag3-via-digest") }) It("should add multiple tags to an existent manifest when providing tag reference", func() { - tagAndValidate(Host, ImageRepo, multi_arch.Tag, multi_arch.Digest, "tag1-via-tag", "tag1-via-tag", "tag1-via-tag") + tagAndValidate(ZOTHost, ImageRepo, multi_arch.Tag, multi_arch.Digest, "tag1-via-tag", "tag1-via-tag", "tag1-via-tag") }) }) }) @@ -75,51 +75,29 @@ var _ = Describe("OCI image layout users:", func() { ORAS("repo", "tags", Flags.Layout, LayoutRef(root, "")).MatchKeyWords(tags...).Exec() } When("running `tag`", func() { - prepare := func() string { - root := GinkgoT().TempDir() - ORAS("cp", RegistryRef(Host, ImageRepo, multi_arch.Tag), Flags.ToLayout, LayoutRef(root, multi_arch.Tag)).Exec() - return root - } It("should add a tag to an existent manifest when providing tag reference", func() { - tagAndValidate(prepare(), multi_arch.Tag, multi_arch.Digest, "tag-via-tag") + tagAndValidate(PrepareTempOCI(ImageRepo), multi_arch.Tag, multi_arch.Digest, "tag-via-tag") }) It("should add a tag to an existent manifest when providing digest reference", func() { - tagAndValidate(prepare(), multi_arch.Digest, multi_arch.Digest, "tag-via-digest") + tagAndValidate(PrepareTempOCI(ImageRepo), multi_arch.Digest, multi_arch.Digest, "tag-via-digest") }) It("should add multiple tags to an existent manifest when providing digest reference", func() { - tagAndValidate(prepare(), multi_arch.Digest, multi_arch.Digest, "tag1-via-digest", "tag2-via-digest", "tag3-via-digest") + tagAndValidate(PrepareTempOCI(ImageRepo), multi_arch.Digest, multi_arch.Digest, "tag1-via-digest", "tag2-via-digest", "tag3-via-digest") }) It("should add multiple tags to an existent manifest when providing tag reference", func() { - tagAndValidate(prepare(), multi_arch.Tag, multi_arch.Digest, "tag1-via-tag", "tag1-via-tag", "tag1-via-tag") + tagAndValidate(PrepareTempOCI(ImageRepo), multi_arch.Tag, multi_arch.Digest, "tag1-via-tag", "tag1-via-tag", "tag1-via-tag") }) - }) -}) - -var _ = Describe("OCI image layout users:", func() { - var tagAndValidate = func(root string, tagOrDigest string, digest string, tags ...string) { - out := ORAS(append([]string{"tag", LayoutRef(root, tagOrDigest), Flags.Layout}, tags...)...).MatchKeyWords(tags...).Exec().Out - hint := regexp.QuoteMeta(fmt.Sprintf("Tagging [oci-layout] %s", LayoutRef(root, digest))) - gomega.Expect(out).To(gbytes.Say(hint)) - gomega.Expect(out).NotTo(gbytes.Say(hint)) // should only say hint once - ORAS("repo", "tags", Flags.Layout, LayoutRef(root, "")).MatchKeyWords(tags...).Exec() - } - When("running `tag`", func() { - prepare := func() string { - root := GinkgoT().TempDir() - ORAS("cp", RegistryRef(Host, ImageRepo, multi_arch.Tag), Flags.ToLayout, LayoutRef(root, multi_arch.Tag)).Exec() - return root - } It("should add a tag to an existent manifest when providing tag reference", func() { - tagAndValidate(prepare(), multi_arch.Tag, multi_arch.Digest, "tag-via-tag") + tagAndValidate(PrepareTempOCI(ImageRepo), multi_arch.Tag, multi_arch.Digest, "tag-via-tag") }) It("should add a tag to an existent manifest when providing digest reference", func() { - tagAndValidate(prepare(), multi_arch.Digest, multi_arch.Digest, "tag-via-digest") + tagAndValidate(PrepareTempOCI(ImageRepo), multi_arch.Digest, multi_arch.Digest, "tag-via-digest") }) It("should add multiple tags to an existent manifest when providing digest reference", func() { - tagAndValidate(prepare(), multi_arch.Digest, multi_arch.Digest, "tag1-via-digest", "tag2-via-digest", "tag3-via-digest") + tagAndValidate(PrepareTempOCI(ImageRepo), multi_arch.Digest, multi_arch.Digest, "tag1-via-digest", "tag2-via-digest", "tag3-via-digest") }) It("should add multiple tags to an existent manifest when providing tag reference", func() { - tagAndValidate(prepare(), multi_arch.Tag, multi_arch.Digest, "tag1-via-tag", "tag1-via-tag", "tag1-via-tag") + tagAndValidate(PrepareTempOCI(ImageRepo), multi_arch.Tag, multi_arch.Digest, "tag1-via-tag", "tag1-via-tag", "tag1-via-tag") }) }) })