From 5f9f780245138d9c8b857820bc0dab5ddcd27fa7 Mon Sep 17 00:00:00 2001 From: Xiaoxuan Wang Date: Sun, 7 Apr 2024 06:18:37 +0000 Subject: [PATCH] added e2e tests Signed-off-by: Xiaoxuan Wang --- test/e2e/suite/command/push.go | 36 ++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/test/e2e/suite/command/push.go b/test/e2e/suite/command/push.go index 741c70e20..b8f5fdbba 100644 --- a/test/e2e/suite/command/push.go +++ b/test/e2e/suite/command/push.go @@ -371,6 +371,42 @@ var _ = Describe("Remote registry users:", func() { Expect(manifest.Config).Should(Equal(artifact.EmptyLayerJSON)) }) + It("should output artifact type when push is complete for image-spec v1.1", func() { + repo := pushTestRepo("print-artifact-type") + tempDir := PrepareTempFiles() + + ORAS("push", RegistryRef(ZOTHost, repo, tag), foobar.FileBarName, "-v", "--image-spec", "v1.1"). + MatchStatus([]match.StateKey{foobar.FileBarStateKey, artifact.DefaultConfigStateKey}, true, 2). + MatchKeyWords("ArtifactType: ", "application/vnd.unknown.artifact.v1"). + WithWorkDir(tempDir).Exec() + + // validate + fetched := ORAS("manifest", "fetch", RegistryRef(ZOTHost, repo, tag)).Exec().Out.Contents() + var manifest ocispec.Manifest + Expect(json.Unmarshal(fetched, &manifest)).ShouldNot(HaveOccurred()) + Expect(manifest.ArtifactType).Should(Equal("application/vnd.unknown.artifact.v1")) + Expect(manifest.Layers).Should(ContainElements(foobar.BlobBarDescriptor("application/vnd.oci.image.layer.v1.tar"))) + Expect(manifest.Config).Should(Equal(artifact.EmptyLayerJSON)) + }) + + It("should output artifact type when push is complete for image-spec v1.0", func() { + repo := pushTestRepo("print-artifact-type") + tempDir := PrepareTempFiles() + + ORAS("push", RegistryRef(ZOTHost, repo, tag), foobar.FileBarName, "-v", "--image-spec", "v1.0"). + MatchStatus([]match.StateKey{foobar.FileBarStateKey, artifact.DefaultConfigStateKey}, true, 2). + MatchKeyWords("ArtifactType: ", "application/vnd.unknown.config.v1+json"). + WithWorkDir(tempDir).Exec() + + // validate + fetched := ORAS("manifest", "fetch", RegistryRef(ZOTHost, repo, tag)).Exec().Out.Contents() + var manifest ocispec.Manifest + Expect(json.Unmarshal(fetched, &manifest)).ShouldNot(HaveOccurred()) + Expect(manifest.ArtifactType).Should(Equal("application/vnd.unknown.artifact.v1")) + Expect(manifest.Layers).Should(ContainElements(foobar.BlobBarDescriptor("application/vnd.oci.image.layer.v1.tar"))) + Expect(manifest.Config).Should(Equal(artifact.EmptyLayerJSON)) + }) + It("should push v1.1-rc.4 artifact", func() { repo := pushTestRepo("v1.1-artifact") tempDir := PrepareTempFiles()