From 6b0132e132166d6ffd8b9d095a1591d6a6ca1696 Mon Sep 17 00:00:00 2001 From: "Lixia (Sylvia) Lei" Date: Mon, 2 Dec 2024 23:02:41 +0800 Subject: [PATCH] attach e2e Signed-off-by: Lixia (Sylvia) Lei --- test/e2e/suite/command/attach.go | 27 +++++++++++++++++++++++++++ test/e2e/suite/command/cp.go | 16 ++++++++-------- test/e2e/suite/command/pull.go | 13 ++++++------- test/e2e/suite/command/push.go | 9 +++------ 4 files changed, 44 insertions(+), 21 deletions(-) diff --git a/test/e2e/suite/command/attach.go b/test/e2e/suite/command/attach.go index f0c6ada5b..5b8797410 100644 --- a/test/e2e/suite/command/attach.go +++ b/test/e2e/suite/command/attach.go @@ -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") }) diff --git a/test/e2e/suite/command/cp.go b/test/e2e/suite/command/cp.go index 4d1b1775d..5fd24fb96 100644 --- a/test/e2e/suite/command/cp.go +++ b/test/e2e/suite/command/cp.go @@ -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() { @@ -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() { diff --git a/test/e2e/suite/command/pull.go b/test/e2e/suite/command/pull.go index e149a8109..9a6c600d8 100644 --- a/test/e2e/suite/command/pull.go +++ b/test/e2e/suite/command/pull.go @@ -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) @@ -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 { diff --git a/test/e2e/suite/command/push.go b/test/e2e/suite/command/push.go index f546d89b3..c5a25fc04 100644 --- a/test/e2e/suite/command/push.go +++ b/test/e2e/suite/command/push.go @@ -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" @@ -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()