Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
Signed-off-by: Xiaoxuan Wang <[email protected]>
  • Loading branch information
Xiaoxuan Wang committed Aug 26, 2024
1 parent 5855f3a commit 7c9cbf8
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 8 deletions.
28 changes: 28 additions & 0 deletions test/e2e/internal/testdata/nonjson_config/const.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
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 nonjson_config

import (
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
)

var (
Descriptor = ocispec.Descriptor{
MediaType: "application/vnd.oci.image.manifest.v1+json",
Digest: "sha256:9d16f5505246424aed7116cb21216704ba8c919997d0f1f37e154c11d509e1d2",
Size: 529,
}
)
26 changes: 18 additions & 8 deletions test/e2e/suite/command/manifest_index.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
. "github.com/onsi/gomega"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"oras.land/oras/test/e2e/internal/testdata/multi_arch"
"oras.land/oras/test/e2e/internal/testdata/nonjson_config"
. "oras.land/oras/test/e2e/internal/utils"
)

Expand Down Expand Up @@ -97,10 +98,15 @@ var _ = Describe("1.1 registry users:", func() {
MatchKeyWords("Fetched", "Pushed", "Tagged",
"sha256:bfa1728d6292d5fa7689f8f4daa145ee6f067b5779528c6e059d1132745ef508").Exec()
// verify
ORAS("manifest", "fetch", RegistryRef(ZOTHost, testRepo, "t0")).Exec()
ORAS("manifest", "fetch", RegistryRef(ZOTHost, testRepo, "t1")).Exec()
ORAS("manifest", "fetch", RegistryRef(ZOTHost, testRepo, "t2")).Exec()
ORAS("manifest", "fetch", RegistryRef(ZOTHost, testRepo, "t3")).Exec()
expectedManifests := []ocispec.Descriptor{multi_arch.LinuxARMV7, multi_arch.LinuxARM64, multi_arch.LinuxAMD64}
content := ORAS("manifest", "fetch", RegistryRef(ZOTHost, testRepo, "t0")).Exec().Out.Contents()
ValidateIndex(content, expectedManifests)
content = ORAS("manifest", "fetch", RegistryRef(ZOTHost, testRepo, "t1")).Exec().Out.Contents()
ValidateIndex(content, expectedManifests)
content = ORAS("manifest", "fetch", RegistryRef(ZOTHost, testRepo, "t2")).Exec().Out.Contents()
ValidateIndex(content, expectedManifests)
content = ORAS("manifest", "fetch", RegistryRef(ZOTHost, testRepo, "t3")).Exec().Out.Contents()
ValidateIndex(content, expectedManifests)
})

It("should create nested indexes", func() {
Expand All @@ -119,7 +125,9 @@ var _ = Describe("1.1 registry users:", func() {
ORAS("manifest", "index", "create", RegistryRef(ZOTHost, testRepo, "unusual-config"),
"nonjson-config").Exec()
// verify
ORAS("manifest", "fetch", RegistryRef(ZOTHost, testRepo, "unusual-config")).Exec()
content := ORAS("manifest", "fetch", RegistryRef(ZOTHost, testRepo, "unusual-config")).Exec().Out.Contents()
expectedManifests := []ocispec.Descriptor{nonjson_config.Descriptor}
ValidateIndex(content, expectedManifests)
})

It("should fail if give a digest as index reference", func() {
Expand Down Expand Up @@ -175,9 +183,9 @@ var _ = Describe("OCI image layout users:", func() {
root := PrepareTempOCI(ImageRepo)
indexRef := LayoutRef(root, "")
ORAS("manifest", "index", "create", Flags.Layout, indexRef, "linux-amd64").
WithWorkDir(root).MatchKeyWords("Digest: sha256:4aa342ba81c63a7c78f8b566c79bc08398d4d712126cb9b3d1d0b1eed69a9a54").Exec()
WithWorkDir(root).MatchKeyWords("Digest: sha256:c543059818cb70e6442597a33454ec1e3d3a2bdb526c17875578d33c2ddcf72e").Exec()
// verify
content := ORAS("manifest", "fetch", Flags.Layout, LayoutRef(root, "sha256:4aa342ba81c63a7c78f8b566c79bc08398d4d712126cb9b3d1d0b1eed69a9a54")).Exec().Out.Contents()
content := ORAS("manifest", "fetch", Flags.Layout, LayoutRef(root, "sha256:c543059818cb70e6442597a33454ec1e3d3a2bdb526c17875578d33c2ddcf72e")).Exec().Out.Contents()
expectedManifests := []ocispec.Descriptor{multi_arch.LinuxAMD64}
ValidateIndex(content, expectedManifests)
})
Expand Down Expand Up @@ -213,7 +221,9 @@ var _ = Describe("OCI image layout users:", func() {
indexRef := LayoutRef(root, "unusual-config")
ORAS("manifest", "index", "create", Flags.Layout, indexRef, "nonjson-config").WithWorkDir(root).Exec()
// verify
ORAS("manifest", "fetch", Flags.Layout, indexRef).Exec()
content := ORAS("manifest", "fetch", Flags.Layout, indexRef).Exec().Out.Contents()
expectedManifests := []ocispec.Descriptor{nonjson_config.Descriptor}
ValidateIndex(content, expectedManifests)
})

It("should fail if give a digest as index reference", func() {
Expand Down

0 comments on commit 7c9cbf8

Please sign in to comment.