Skip to content

Commit

Permalink
blob 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 5, 2024
1 parent d536c7b commit 1ee2c87
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
25 changes: 25 additions & 0 deletions test/e2e/suite/command/blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"github.com/onsi/gomega/gbytes"
"oras.land/oras/test/e2e/internal/testdata/foobar"
. "oras.land/oras/test/e2e/internal/utils"
"oras.land/oras/test/e2e/internal/utils/match"
)

const (
Expand All @@ -39,6 +40,30 @@ var _ = Describe("ORAS beginners:", func() {
repoFmt := fmt.Sprintf("command/blob/%%s/%d/%%s", GinkgoRandomSeed())
When("running blob command", func() {
When("running `blob push`", func() {
It("should not show --verbose in help doc", func() {
out := ORAS("push", "--help").MatchKeyWords(ExampleDesc).Exec().Out
gomega.Expect(out).ShouldNot(gbytes.Say("--verbose"))
})

It("should show deprecation message and print unnamed status output for --verbose", func() {
repo := fmt.Sprintf(repoFmt, "push", "test-verbose")
ORAS("blob", "push", RegistryRef(ZOTHost, repo, pushDigest), "-", "--size", strconv.Itoa(len(pushContent)), "--verbose").
WithInput(strings.NewReader(pushContent)).
MatchErrKeyWords(DeprecationMessageVerboseFlag).
MatchStatus([]match.StateKey{{Digest: "e1ca41574914", Name: "application/vnd.oci.image.layer.v1.tar"}}, true, 1).
Exec()
})

It("should show deprecation message and should NOT print unnamed status output for --verbose=false", func() {
repo := fmt.Sprintf(repoFmt, "push", "test-verbose-false")
out := ORAS("blob", "push", RegistryRef(ZOTHost, repo, pushDigest), "-", "--size", strconv.Itoa(len(pushContent)), "--verbose=false").
WithInput(strings.NewReader(pushContent)).
MatchErrKeyWords(DeprecationMessageVerboseFlag).
Exec()
// should not print status output for unnamed blobs
gomega.Expect(out).ShouldNot(gbytes.Say("application/vnd.oci.image.layer.v1.tar"))
})

It("should fail to read blob content and password from stdin at the same time", func() {
repo := fmt.Sprintf(repoFmt, "push", "password-stdin")
ORAS("blob", "push", RegistryRef(ZOTHost, repo, ""), "--password-stdin", "-").
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/suite/command/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ var _ = Describe("ORAS beginners:", func() {

tag := "test-verbose"
ORAS("manifest", "push", RegistryRef(ZOTHost, ImageRepo, tag), "-", "--verbose").
WithInput(strings.NewReader(manifest)).
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()
})

Expand All @@ -85,9 +85,9 @@ var _ = Describe("ORAS beginners:", func() {

tag := "test-verbose-false"
out := ORAS("manifest", "push", RegistryRef(ZOTHost, ImageRepo, tag), "-", "--verbose=false").
WithInput(strings.NewReader(manifest)).
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"))
Expand Down

0 comments on commit 1ee2c87

Please sign in to comment.