Skip to content

Commit

Permalink
added e2e tests
Browse files Browse the repository at this point in the history
Signed-off-by: Xiaoxuan Wang <[email protected]>
  • Loading branch information
wangxiaoxuan273 committed Apr 7, 2024
1 parent cb31e3c commit 5f9f780
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions test/e2e/suite/command/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 5f9f780

Please sign in to comment.