Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(e2e): OCI layout specs for oras tag #902

Merged
merged 2 commits into from
Apr 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions test/e2e/suite/command/tag.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,61 @@ var _ = Describe("Common registry users:", func() {
})
})
})

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")
})
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")
})
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")
})
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")
})
})
})

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")
})
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")
})
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")
})
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")
})
})
})