-
Notifications
You must be signed in to change notification settings - Fork 174
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add E2E specs covering
repo
subcommand (#716)
Resolves #714 Signed-off-by: Billy Zha <jinzha1@microsoft.com>
- Loading branch information
Showing
4 changed files
with
92 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/* | ||
Copyright The ORAS Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package command | ||
|
||
import ( | ||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
"github.com/onsi/gomega/gbytes" | ||
. "oras.land/oras/test/e2e/internal/utils" | ||
) | ||
|
||
var _ = Describe("ORAS beginners:", func() { | ||
When("running repo command", func() { | ||
runAndShowPreviewInHelp([]string{"repo"}) | ||
When("running `repo ls`", func() { | ||
It("should show preview in help", func() { | ||
ORAS("repo", "ls", "--help").MatchKeyWords("[Preview] List", preview_desc, example_desc).Exec() | ||
}) | ||
|
||
It("should call sub-commands with aliases", func() { | ||
ORAS("repository", "list", "--help").MatchKeyWords("[Preview] List", preview_desc, example_desc).Exec() | ||
}) | ||
|
||
It("should fail listing repositories if wrong registry provided", func() { | ||
ORAS("repo", "ls").WithFailureCheck().MatchErrKeyWords("Error:").Exec() | ||
ORAS("repo", "ls", Reference(Host, repo, "")).WithFailureCheck().MatchErrKeyWords("Error:").Exec() | ||
ORAS("repo", "ls", Reference(Host, repo, "some-tag")).WithFailureCheck().MatchErrKeyWords("Error:").Exec() | ||
}) | ||
}) | ||
When("running `repo tags`", func() { | ||
It("should show preview in help", func() { | ||
ORAS("repo", "tags", "--help").MatchKeyWords("[Preview] Show tags", preview_desc, example_desc).Exec() | ||
}) | ||
|
||
It("should call sub-commands with aliases", func() { | ||
ORAS("repository", "show-tags", "--help").MatchKeyWords("[Preview] Show tags", preview_desc, example_desc).Exec() | ||
}) | ||
|
||
It("should fail listing repositories if wrong registry provided", func() { | ||
ORAS("repo", "tags").WithFailureCheck().MatchErrKeyWords("Error:").Exec() | ||
ORAS("repo", "tags", Host).WithFailureCheck().MatchErrKeyWords("Error:").Exec() | ||
ORAS("repo", "tags", Reference(Host, repo, "some-tag")).WithFailureCheck().MatchErrKeyWords("Error:").Exec() | ||
}) | ||
}) | ||
}) | ||
}) | ||
|
||
var _ = Describe("Common registry users:", func() { | ||
When("running `repo ls`", func() { | ||
It("should list repositories", func() { | ||
ORAS("repository", "list", Host).MatchKeyWords(repo).Exec() | ||
}) | ||
It("should list repositories via short command", func() { | ||
ORAS("repo", "ls", Host).MatchKeyWords(repo).Exec() | ||
}) | ||
It("should list partial repositories via `last` flag", func() { | ||
session := ORAS("repo", "ls", Host, "--last", repo).Exec() | ||
Expect(session.Out).ShouldNot(gbytes.Say(repo)) | ||
}) | ||
}) | ||
When("running `repo tags`", func() { | ||
repoRef := Reference(Host, repo, "") | ||
It("should list tags", func() { | ||
ORAS("repository", "show-tags", repoRef).MatchKeyWords(multiImage, foobarImageTag).Exec() | ||
}) | ||
It("should list tags via short command", func() { | ||
ORAS("repo", "tags", repoRef).MatchKeyWords(multiImage, foobarImageTag).Exec() | ||
|
||
}) | ||
It("should list partial tags via `last` flag", func() { | ||
session := ORAS("repo", "tags", repoRef, "--last", foobarImageTag).MatchKeyWords(multiImage).Exec() | ||
Expect(session.Out).ShouldNot(gbytes.Say(foobarImageTag)) | ||
}) | ||
}) | ||
}) |