Skip to content

Commit

Permalink
manifest push e2e
Browse files Browse the repository at this point in the history
Signed-off-by: Lixia (Sylvia) Lei <[email protected]>
  • Loading branch information
Wwwsylvia committed Dec 3, 2024
1 parent 9fe1cb4 commit 45dd023
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
3 changes: 3 additions & 0 deletions test/e2e/internal/utils/match/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ func newStateMachine(cmd string) *stateMachine {
sm.addPath("Skipped")
sm.addPath("Exists")
sm.addPath("Mounted")
case "manifest", "blob": // for `manifest push` and `blob push`
sm.addPath("Uploading", "Uploaded")
sm.addPath("Exists")
default:
ginkgo.Fail("Unrecognized cmd name " + cmd)
}
Expand Down
30 changes: 30 additions & 0 deletions test/e2e/suite/command/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
"oras.land/oras/test/e2e/internal/testdata/foobar"
"oras.land/oras/test/e2e/internal/testdata/multi_arch"
. "oras.land/oras/test/e2e/internal/utils"
"oras.land/oras/test/e2e/internal/utils/match"
)

func prepare(src string, dst string) {
Expand All @@ -55,6 +56,8 @@ var _ = Describe("ORAS beginners:", func() {
It("should show help doc with feature flags", func() {
out := ORAS("manifest", "push", "--help").MatchKeyWords(ExampleDesc).Exec()
gomega.Expect(out).Should(gbytes.Say("--distribution-spec string\\s+%s", regexp.QuoteMeta(feature.Preview.Mark)))
// verbose flag should be hidden in help doc
gomega.Expect(out).ShouldNot(gbytes.Say("--verbose"))
})

It("should have flag for prettifying JSON output", func() {
Expand All @@ -63,6 +66,33 @@ var _ = Describe("ORAS beginners:", func() {
Exec()
})

It("should show deprecation message and print unnamed status output for --verbose", func() {
manifest := `{"schemaVersion":2,"mediaType":"application/vnd.oci.image.manifest.v1+json","config":{"mediaType":"application/vnd.oci.image.config.v1+json","digest":"sha256:fe9dbc99451d0517d65e048c309f0b5afb2cc513b7a3d456b6cc29fe641386c5","size":53},"layers":[]}`
manifestDigest := "sha256:bc1a59d49fc7c7b0a31f22ca0c743ecdabdb736777e3d9672fa9d97b4fe323f4"

tag := "test-verbose"
ORAS("manifest", "push", RegistryRef(ZOTHost, ImageRepo, tag), "-", "--verbose").
MatchErrKeyWords(DeprecationMessageVerboseFlag).
MatchKeyWords("Pushed", RegistryRef(ZOTHost, ImageRepo, tag), "Digest:", manifestDigest).
MatchStatus([]match.StateKey{{Digest: "bc1a59d49fc7", Name: "application/vnd.oci.image.manifest.v1+json"}}, true, 1).
WithInput(strings.NewReader(manifest)).
Exec()
})

It("should show deprecation message and should NOT print unnamed status output for --verbose=false", func() {
manifest := `{"schemaVersion":2,"mediaType":"application/vnd.oci.image.manifest.v1+json","config":{"mediaType":"application/vnd.oci.image.config.v1+json","digest":"sha256:fe9dbc99451d0517d65e048c309f0b5afb2cc513b7a3d456b6cc29fe641386c5","size":53},"layers":[]}`
manifestDigest := "sha256:bc1a59d49fc7c7b0a31f22ca0c743ecdabdb736777e3d9672fa9d97b4fe323f4"

tag := "test-verbose-false"
out := ORAS("manifest", "push", RegistryRef(ZOTHost, ImageRepo, tag), "-", "--verbose=false").
MatchErrKeyWords(DeprecationMessageVerboseFlag).
MatchKeyWords("Pushed", RegistryRef(ZOTHost, ImageRepo, tag), "Digest:", manifestDigest).
WithInput(strings.NewReader(manifest)).
Exec()
// should not print status output for unnamed blobs
gomega.Expect(out).ShouldNot(gbytes.Say("application/vnd.oci.image.manifest.v1+json"))
})

It("should fail and show detailed error description if no argument provided", func() {
err := ORAS("manifest", "push").ExpectFailure().Exec().Err
gomega.Expect(err).Should(gbytes.Say("Error"))
Expand Down

0 comments on commit 45dd023

Please sign in to comment.