From 43196b041129146cd7d93ccb7d7ac841b2528007 Mon Sep 17 00:00:00 2001 From: Billy Zha Date: Wed, 31 May 2023 07:28:59 +0000 Subject: [PATCH 1/2] fix: correct spec flag description Signed-off-by: Billy Zha --- cmd/oras/internal/option/spec.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/oras/internal/option/spec.go b/cmd/oras/internal/option/spec.go index 9d994ff02..ccbb204fb 100644 --- a/cmd/oras/internal/option/spec.go +++ b/cmd/oras/internal/option/spec.go @@ -71,7 +71,7 @@ func (opts *distributionSpec) Parse() error { isApi := true opts.referrersAPI = &isApi default: - return fmt.Errorf("unknown image specification flag: %q", opts.specFlag) + return fmt.Errorf("unknown distribution specification flag: %q", opts.specFlag) } return nil } From 3cd48fba110a52fae58a836cd749d47c93f58a6d Mon Sep 17 00:00:00 2001 From: Billy Zha Date: Wed, 31 May 2023 07:38:38 +0000 Subject: [PATCH 2/2] add e2e tests Signed-off-by: Billy Zha --- test/e2e/suite/command/attach.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/e2e/suite/command/attach.go b/test/e2e/suite/command/attach.go index e761a1a0e..54c35f6c3 100644 --- a/test/e2e/suite/command/attach.go +++ b/test/e2e/suite/command/attach.go @@ -60,6 +60,16 @@ var _ = Describe("ORAS beginners:", func() { ORAS("attach", "--artifact-type", "oras.test", LayoutRef(root, foobar.Tag)). ExpectFailure().MatchErrKeyWords("Error: no blob or manifest annotation are provided").Exec() }) + + It("should fail if distribution spec is unkown", func() { + ORAS("attach", "--artifact-type", "oras.test", RegistryRef(Host, ImageRepo, foobar.Tag), "--distribution-spec", "???"). + ExpectFailure().MatchErrKeyWords("unknown distribution specification flag").Exec() + }) + + It("should fail if image spec is unkown", func() { + ORAS("attach", "--artifact-type", "oras.test", RegistryRef(Host, ImageRepo, foobar.Tag), "--image-spec", "???"). + ExpectFailure().MatchErrKeyWords("unknown image specification flag").Exec() + }) }) })