From 1c02003b5705fdc7fe9488c648ef6f83f5c95b0f Mon Sep 17 00:00:00 2001 From: Sajay Antony Date: Wed, 15 Nov 2023 00:13:31 +0000 Subject: [PATCH] test: Added tests for resolve command Signed-off-by: Sajay Antony --- test/e2e/suite/command/resolve.go | 53 +++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 test/e2e/suite/command/resolve.go diff --git a/test/e2e/suite/command/resolve.go b/test/e2e/suite/command/resolve.go new file mode 100644 index 000000000..bff183fc4 --- /dev/null +++ b/test/e2e/suite/command/resolve.go @@ -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))) + }) + }) +})