Skip to content

Commit

Permalink
attach 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 2, 2024
1 parent bbf8b63 commit 6b0132e
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 21 deletions.
27 changes: 27 additions & 0 deletions test/e2e/suite/command/attach.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,36 @@ var _ = Describe("ORAS beginners:", func() {

It("should show preview and help doc", func() {
out := ORAS("attach", "--help").MatchKeyWords(feature.Preview.Mark+" Attach", feature.Preview.Description, ExampleDesc).Exec()
// verbose flag should be hidden in help doc
gomega.Expect(out).Should(gbytes.Say("--distribution-spec string\\s+%s", regexp.QuoteMeta(feature.Preview.Mark)))
})

It("should show deprecation message and print unnamed status output for --verbose", func() {
testRepo := attachTestRepo("test-verbose")
CopyZOTRepo(ImageRepo, testRepo)
subjectRef := RegistryRef(ZOTHost, testRepo, foobar.Tag)
stateKeys := []match.StateKey{
foobar.AttachFileStateKey,
{Digest: "44136fa355b3", Name: "application/vnd.oci.empty.v1+json"},
}
ORAS("attach", "--artifact-type", "test/attach", "--verbose", subjectRef, fmt.Sprintf("%s:%s", foobar.AttachFileName, foobar.AttachFileMedia)).
WithWorkDir(PrepareTempFiles()).
MatchErrKeyWords(DeprecationMessageVerboseFlag).
MatchStatus(stateKeys, true, len(stateKeys)).Exec()
})

It("should show deprecation message and should NOT print unnamed status output for --verbose=false", func() {
testRepo := attachTestRepo("test-verbose-false")
CopyZOTRepo(ImageRepo, testRepo)
subjectRef := RegistryRef(ZOTHost, testRepo, foobar.Tag)
stateKeys := []match.StateKey{foobar.AttachFileStateKey}
out := ORAS("attach", "--artifact-type", "test/attach", "--verbose=false", subjectRef, fmt.Sprintf("%s:%s", foobar.AttachFileName, foobar.AttachFileMedia)).
WithWorkDir(PrepareTempFiles()).
MatchErrKeyWords(DeprecationMessageVerboseFlag).
MatchStatus(stateKeys, false, len(stateKeys)).Exec()
gomega.Expect(out).ShouldNot(gbytes.Say("application/vnd.oci.empty.v1+json"))
})

It("should show text as default format type in help doc", func() {
MatchDefaultFlagValue("format", "text", "attach")
})
Expand Down
16 changes: 8 additions & 8 deletions test/e2e/suite/command/cp.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,8 @@ var _ = Describe("ORAS beginners:", func() {
Expect(out).Should(gbytes.Say("--from-distribution-spec string\\s+%s", regexp.QuoteMeta(feature.Preview.Mark)))
Expect(out).Should(gbytes.Say("-r, --recursive\\s+%s", regexp.QuoteMeta(feature.Preview.Mark)))
Expect(out).Should(gbytes.Say("--to-distribution-spec string\\s+%s", regexp.QuoteMeta(feature.Preview.Mark)))
})

It("should not show --verbose in help doc", func() {
out := ORAS("push", "--help").MatchKeyWords(ExampleDesc).Exec().Out
gomega.Expect(out).ShouldNot(gbytes.Say("--verbose"))
// verbose flag should be hidden in help doc
Expect(out).ShouldNot(gbytes.Say("--verbose"))
})

It("should show deprecation message and print unnamed status output for --verbose", func() {
Expand All @@ -65,17 +62,20 @@ var _ = Describe("ORAS beginners:", func() {
CompareRef(src, dst)
})

It("should show deprecation message and print unnamed status output for --verbose=false", func() {
It("should show deprecation message and should NOT print unnamed status output for --verbose=false", func() {
src := RegistryRef(ZOTHost, ArtifactRepo, blob.Tag)
dst := RegistryRef(ZOTHost, cpTestRepo("test-verbose-false"), "copied")
stateKeys := []match.StateKey{
{Digest: "2ef548696ac7", Name: "hello.tar"},
}
ORAS("cp", src, dst, "--verbose=false").
out := ORAS("cp", src, dst, "--verbose=false").
MatchErrKeyWords(DeprecationMessageVerboseFlag).
MatchStatus(stateKeys, true, len(stateKeys)).
MatchStatus(stateKeys, false, len(stateKeys)).
Exec()
CompareRef(src, dst)
// should not print status output for unnamed blobs
gomega.Expect(out).ShouldNot(gbytes.Say("application/vnd.oci.empty.v1+json"))
gomega.Expect(out).ShouldNot(gbytes.Say("application/vnd.oci.image.manifest.v1+json"))
})

It("should fail when no reference provided", func() {
Expand Down
13 changes: 6 additions & 7 deletions test/e2e/suite/command/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,14 @@ var _ = Describe("ORAS beginners:", func() {
It("should show help description with feature flags", func() {
out := ORAS("pull", "--help").MatchKeyWords(ExampleDesc).Exec().Out
gomega.Expect(out).Should(gbytes.Say("--include-subject\\s+%s", regexp.QuoteMeta(feature.Preview.Mark)))
// verbose flag should be hidden in help doc
gomega.Expect(out).ShouldNot(gbytes.Say("--verbose"))
})

It("should show text as default format type in help doc", func() {
MatchDefaultFlagValue("format", "text", "pull")
})

It("should not show --verbose in help doc", func() {
out := ORAS("pull", "--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() {
tempDir := PrepareTempFiles()
ref := RegistryRef(ZOTHost, ImageRepo, foobar.Tag)
Expand All @@ -67,11 +64,13 @@ var _ = Describe("ORAS beginners:", func() {
tempDir := PrepareTempFiles()
ref := RegistryRef(ZOTHost, ImageRepo, foobar.Tag)
stateKeys := foobar.ImageLayerStateKeys
ORAS("pull", ref, "--verbose=false").
out := ORAS("pull", ref, "--verbose=false").
WithWorkDir(tempDir).
MatchErrKeyWords(DeprecationMessageVerboseFlag).
MatchStatus(stateKeys, true, len(stateKeys)).
MatchStatus(stateKeys, false, len(stateKeys)).
Exec()
// should not print status output for unnamed blobs
gomega.Expect(out).ShouldNot(gbytes.Say("application/vnd.oci.image.manifest.v1+json"))
})

hintMsg := func(reference string) string {
Expand Down
9 changes: 3 additions & 6 deletions test/e2e/suite/command/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,14 @@ var _ = Describe("ORAS beginners:", func() {
It("should show help description with feature flags", func() {
out := ORAS("push", "--help").MatchKeyWords(ExampleDesc).Exec().Out
gomega.Expect(out).Should(gbytes.Say("--image-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 show text as default format type in help doc", func() {
MatchDefaultFlagValue("format", "text", "push")
})

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 := pushTestRepo("test-verbose")
tag := "e2e"
Expand All @@ -65,7 +62,7 @@ var _ = Describe("ORAS beginners:", func() {
Exec()
})

It("should show deprecation message and print unnamed status output for --verbose=false", func() {
It("should show deprecation message and should NOT print unnamed status output for --verbose=false", func() {
repo := pushTestRepo("test-verbose-false")
tag := "e2e"
tempDir := PrepareTempFiles()
Expand Down

0 comments on commit 6b0132e

Please sign in to comment.