Skip to content

Commit

Permalink
test: add e2e specs covering oras tag (oras-project#718)
Browse files Browse the repository at this point in the history
Resolves oras-project#717

Signed-off-by: Billy Zha <jinzha1@microsoft.com>
  • Loading branch information
qweeah authored and Terry Howe committed Feb 2, 2023
1 parent 1015ac5 commit dfc859b
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/e2e/suite/auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ var _ = Describe("Common registry user", Ordered, func() {
RunWithoutLogin("push", "-a", "key=value", Host+"/repo:tag")
RunWithoutLogin("pull", Host+"/repo:tag")
RunWithoutLogin("manifest", "fetch", Host+"/repo:tag")
RunWithoutLogin("tag", Host+"/repo:tag", "tag1")
RunWithoutLogin("repo", "ls", Host)
RunWithoutLogin("repo", "tags", Reference(Host, "repo", ""))
RunWithoutLogin("manifest", "fetch-config", Host+"/repo:tag")
Expand Down
57 changes: 57 additions & 0 deletions test/e2e/suite/command/tag.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
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 (
"fmt"

. "github.com/onsi/ginkgo/v2"
. "oras.land/oras/test/e2e/internal/utils"
)

var repoFmt = fmt.Sprintf("command/tag/%%s/%d/%%s", GinkgoRandomSeed())

var _ = Describe("ORAS beginners:", func() {
When("running repo command", func() {
runAndShowPreviewInHelp([]string{"tag"})
It("should fail when no manifest reference provided", func() {
ORAS("tag").WithFailureCheck().MatchErrKeyWords("Error:").Exec()
})

It("should fail when provided manifest reference is not found", func() {
ORAS("tag", Reference(Host, repo, "i-dont-think-this-tag-exists")).WithFailureCheck().MatchErrKeyWords("Error:").Exec()
})
})
})

var _ = Describe("Common registry users:", func() {
var tagAndValidate = func(reg string, repo string, tagOrDigest string, tags ...string) {
ORAS(append([]string{"tag", Reference(reg, repo, tagOrDigest)}, tags...)...).MatchKeyWords(tags...).Exec()
ORAS("repo", "tags", Reference(reg, repo, "")).MatchKeyWords(tags...).Exec()
}
When("running `tag`", func() {
It("should add a tag to an existent manifest when providing tag reference", func() {
tagAndValidate(Host, repo, multiImage, "tag-via-tag")
})
It("should add a tag to an existent manifest when providing digest reference", func() {
tagAndValidate(Host, repo, digest_multi, "tag-via-digest")
})
It("should add multiple tags to an existent manifest when providing digest reference", func() {
tagAndValidate(Host, repo, digest_multi, "tag1-via-digest", "tag2-via-digest", "tag3-via-digest")
})
It("should add multiple tags to an existent manifest when providing tag reference", func() {
tagAndValidate(Host, repo, multiImage, "tag1-via-tag", "tag1-via-tag", "tag1-via-tag")
})
})
})

0 comments on commit dfc859b

Please sign in to comment.