Skip to content

Commit

Permalink
fix e2e
Browse files Browse the repository at this point in the history
Signed-off-by: Billy Zha <[email protected]>
  • Loading branch information
qweeah committed Aug 28, 2023
1 parent 8295d85 commit dea043d
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 19 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,6 @@ test/e2e/testdata/distribution/mount_fallback/docker/
# OCI Layout Files ZOT storage files for local E2E testing
test/e2e/testdata/zot/
!test/e2e/testdata/zot/command/images
!test/e2e/testdata/zot/command/blobs
!test/e2e/testdata/zot/config.json
!test/e2e/testdata/zot/passwd_bcrypt
2 changes: 1 addition & 1 deletion test/e2e/internal/utils/testdata.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ const (
PreviewDesc = "** This command is in preview and under development. **"
ExampleDesc = "\nExample - "
ImageRepo = "command/images"
BlobRepo = "command/blobs"
ArtifactRepo = "command/artifacts"
Repo = "command/images"
Namespace = "command"
// env
RegHostKey = "ORAS_REGISTRY_HOST"
Expand Down
16 changes: 6 additions & 10 deletions test/e2e/suite/command/blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,11 @@ var _ = Describe("ORAS beginners:", func() {
})

It("should fail to push a blob from stdin if invalid blob size provided", func() {
content := "another-test"
digest := "sha256:c897eff15c4586525388034f8246346681cb48d75a619039c566c4939a18102e"
repo := fmt.Sprintf(repoFmt, "push", "invalid-stdin-size")
ORAS("blob", "push", RegistryRef(ZOTHost, repo, pushDigest), "-", "--size", "3").
WithInput(strings.NewReader(pushContent)).ExpectFailure().
ORAS("blob", "push", RegistryRef(ZOTHost, repo, digest), "-", "--size", "3").
WithInput(strings.NewReader(content)).ExpectFailure().
Exec()
})

Expand Down Expand Up @@ -169,24 +171,18 @@ var _ = Describe("1.1 registry users:", func() {
When("running `blob delete`", func() {
It("should delete a blob with interactive confirmation", func() {
dstRepo := fmt.Sprintf(repoFmt, "delete", "prompt-confirmation")
CopyZOTRepo(ImageRepo, dstRepo)
CopyZOTRepo(BlobRepo, dstRepo)
toDeleteRef := RegistryRef(ZOTHost, dstRepo, foobar.FooBlobDigest)
ORAS("blob", "delete", toDeleteRef).
WithInput(strings.NewReader("y")).
MatchKeyWords("Deleted", toDeleteRef).Exec()
ORAS("blob", "delete", toDeleteRef).
WithDescription("validate").
WithInput(strings.NewReader("y")).
ExpectFailure().
MatchErrKeyWords("Error:", toDeleteRef, "the specified blob does not exist").Exec()
})

It("should delete a blob with force flag and output descriptor", func() {
dstRepo := fmt.Sprintf(repoFmt, "delete", "flag-confirmation")
CopyZOTRepo(ImageRepo, dstRepo)
CopyZOTRepo(BlobRepo, dstRepo)
toDeleteRef := RegistryRef(ZOTHost, dstRepo, foobar.FooBlobDigest)
ORAS("blob", "delete", toDeleteRef, "--force", "--descriptor").MatchContent(foobar.FooBlobDescriptor).Exec()
ORAS("blob", "delete", toDeleteRef).WithDescription("validate").ExpectFailure().MatchErrKeyWords("Error:", toDeleteRef, "the specified blob does not exist").Exec()
})

It("should return success when deleting a non-existent blob with force flag set", func() {
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/suite/command/discover.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ var _ = Describe("ORAS beginners:", func() {
})

It("should fail when no tag or digest found in provided subject reference", func() {
ORAS("discover", RegistryRef(Host, Repo, "")).ExpectFailure().MatchErrKeyWords("Error:", "invalid image reference").Exec()
ORAS("discover", RegistryRef(Host, ImageRepo, "")).ExpectFailure().MatchErrKeyWords("Error:", "invalid image reference").Exec()
})
})
})
Expand Down
14 changes: 7 additions & 7 deletions test/e2e/suite/command/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ var _ = Describe("ORAS beginners:", func() {

It("should fail listing repositories if wrong registry provided", func() {
ORAS("repo", "ls").ExpectFailure().MatchErrKeyWords("Error:").Exec()
ORAS("repo", "ls", RegistryRef(Host, Repo, "some-tag")).ExpectFailure().MatchErrKeyWords("Error:").Exec()
ORAS("repo", "ls", RegistryRef(Host, ImageRepo, "some-tag")).ExpectFailure().MatchErrKeyWords("Error:").Exec()
})
})
When("running `repo tags`", func() {
Expand Down Expand Up @@ -70,16 +70,16 @@ var _ = Describe("1.1 registry users:", func() {
ORAS("repository", "list", Host).MatchKeyWords(ImageRepo).Exec()
})
It("should list repositories under provided namespace", func() {
ORAS("repo", "ls", RegistryRef(Host, Namespace, "")).MatchKeyWords(Repo[len(Namespace)+1:]).Exec()
ORAS("repo", "ls", RegistryRef(Host, Namespace, "")).MatchKeyWords(ImageRepo[len(Namespace)+1:]).Exec()
})

It("should not list repositories without a fully matched namespace", func() {
repo := "command-draft/images"
ORAS("cp", RegistryRef(Host, Repo, foobar.Tag), RegistryRef(Host, repo, foobar.Tag)).
ORAS("cp", RegistryRef(Host, ImageRepo, foobar.Tag), RegistryRef(Host, repo, foobar.Tag)).
WithDescription("prepare destination repo: " + repo).
Exec()
ORAS("repo", "ls", Host).MatchKeyWords(Repo, repo).Exec()
session := ORAS("repo", "ls", RegistryRef(Host, Namespace, "")).MatchKeyWords(Repo[len(Namespace)+1:]).Exec()
ORAS("repo", "ls", Host).MatchKeyWords(ImageRepo, repo).Exec()
session := ORAS("repo", "ls", RegistryRef(Host, Namespace, "")).MatchKeyWords(ImageRepo[len(Namespace)+1:]).Exec()
Expect(session.Out).ShouldNot(gbytes.Say(repo[len(Namespace)+1:]))
})

Expand Down Expand Up @@ -115,10 +115,10 @@ var _ = Describe("1.1 registry users:", func() {
repo := repoWithName("filter-tag")
tags := []string{foobar.Tag, "bax", "bay", "baz"}
refWithTags := fmt.Sprintf("%s:%s", RegistryRef(Host, repo, ""), strings.Join(tags, ","))
ORAS("cp", RegistryRef(Host, Repo, foobar.Tag), refWithTags).
ORAS("cp", RegistryRef(Host, ImageRepo, foobar.Tag), refWithTags).
WithDescription("prepare: copy and create multiple tags to " + refWithTags).
Exec()
ORAS("cp", RegistryRef(Host, Repo, multi_arch.Tag), RegistryRef(Host, Repo, "")).
ORAS("cp", RegistryRef(Host, ImageRepo, multi_arch.Tag), RegistryRef(Host, ImageRepo, "")).
WithDescription("prepare: copy tag with different digest").
Exec()
// test
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
foo
1 change: 1 addition & 0 deletions test/e2e/testdata/zot/command/blobs/index.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"schemaVersion":2,"manifests":null}
1 change: 1 addition & 0 deletions test/e2e/testdata/zot/command/blobs/oci-layout
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"imageLayoutVersion":"1.0.0"}

0 comments on commit dea043d

Please sign in to comment.