Skip to content

Commit

Permalink
add e2e for discover
Browse files Browse the repository at this point in the history
Signed-off-by: Billy Zha <[email protected]>
  • Loading branch information
qweeah committed Jan 25, 2024
1 parent b7c052c commit 8a0fb69
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions test/e2e/suite/command/discover.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ var _ = Describe("ORAS beginners:", func() {
ORAS("discover", RegistryRef(ZOTHost, ImageRepo, "")).ExpectFailure().MatchErrKeyWords("Error:", "no tag or digest specified", "oras discover").Exec()
})

It("should fail if both output and format flags are used", func() {
ORAS("discover", RegistryRef(ZOTHost, ImageRepo, foobar.Tag), "--format", "json", "--output", "json").
ExpectFailure().
Exec()
})

It("should fail and show detailed error description if no argument provided", func() {
err := ORAS("discover").ExpectFailure().Exec().Err
Expect(err).Should(gbytes.Say("Error"))
Expand Down Expand Up @@ -119,8 +125,13 @@ var _ = Describe("1.1 registry users:", func() {
})

When("running discover command with tree output", func() {
format := "tree"
referrers := []ocispec.Descriptor{foobar.SBOMImageReferrer, foobar.SBOMImageReferrer, foobar.SignatureImageReferrer, foobar.SignatureImageReferrer}
It("should show as tree by default", func() {
ORAS("discover", subjectRef).
MatchKeyWords(append(discoverKeyWords(false, referrers...), RegistryRef(ZOTHost, ArtifactRepo, foobar.Digest))...).
Exec()
})
format := "tree"
It("should discover all referrers of a subject", func() {
ORAS("discover", subjectRef, "-o", format).
MatchKeyWords(append(discoverKeyWords(false, referrers...), RegistryRef(ZOTHost, ArtifactRepo, foobar.Digest))...).
Expand All @@ -137,7 +148,6 @@ var _ = Describe("1.1 registry users:", func() {
ORAS("discover", subjectRef, "-o", format, "-v").
MatchKeyWords(append(discoverKeyWords(true, referrers...), RegistryRef(ZOTHost, ArtifactRepo, foobar.Digest))...).
Exec()

})
})
When("running discover command with table output", func() {
Expand Down Expand Up @@ -282,7 +292,6 @@ var _ = Describe("OCI image layout users:", func() {
})

It("should discover no matched referrer", func() {
// prepare
root := PrepareTempOCI(ArtifactRepo)
subjectRef := LayoutRef(root, foobar.Tag)
out := ORAS("discover", subjectRef, "-o", format, "--artifact-type", "???", Flags.Layout).Exec().Out
Expand Down

0 comments on commit 8a0fb69

Please sign in to comment.