Skip to content

Commit

Permalink
test: Added tests for resolve command
Browse files Browse the repository at this point in the history
Signed-off-by: Sajay Antony <sajaya@microsoft.com>
  • Loading branch information
sajayantony committed Nov 15, 2023
1 parent 6f73bda commit 1c02003
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions test/e2e/suite/command/resolve.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
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"
"strings"

. "github.com/onsi/ginkgo/v2"
"github.com/onsi/gomega"
"github.com/onsi/gomega/gbytes"
"oras.land/oras/test/e2e/internal/testdata/multi_arch"
. "oras.land/oras/test/e2e/internal/utils"
)

var _ = Describe("ORAS beginners:", Focus, func() {
When("running resolve command", func() {
It("should fail when no manifest reference provided", func() {
ORAS("resolve").ExpectFailure().MatchErrKeyWords("Error:").Exec()
})
It("should fail when provided manifest reference is not found", func() {
ORAS("resolve", RegistryRef(ZOTHost, ImageRepo, "i-dont-think-this-tag-exists")).ExpectFailure().MatchErrKeyWords("Error: failed to resolve digest:", "not found").Exec()
})
It("should resolve with with just digest", func() {
out := ORAS("resolve", RegistryRef(ZOTHost, ImageRepo, multi_arch.Digest)).Exec().Out
outString := string(out.Contents())
outString = strings.TrimSpace(outString)
gomega.Expect(outString).To(gomega.Equal(multi_arch.Digest))

})
It("should resolve with with the fully qualified reference", func() {
out := ORAS("resolve", "-l", RegistryRef(ZOTHost, ImageRepo, multi_arch.Tag)).Exec().Out
gomega.Expect(out).To(gbytes.Say(fmt.Sprintf("%s/%s@%s", ZOTHost, ImageRepo, multi_arch.Digest)))
})
It("should resolve with a fully qualified reference for a platform", func() {
out := ORAS("resolve", "--full-reference", "--platform", "linux/amd64", RegistryRef(ZOTHost, ImageRepo, multi_arch.Tag)).Exec().Out
gomega.Expect(out).To(gbytes.Say(fmt.Sprintf("%s/%s@%s", ZOTHost, ImageRepo, multi_arch.LinuxAMD64.Digest)))
})
})
})

0 comments on commit 1c02003

Please sign in to comment.