test: make test layouts smaller

This commit is contained in:
mrjoelkamp
2024-09-19 15:31:37 -05:00
parent fd4e741a1f
commit 0378c94226
86 changed files with 129 additions and 943 deletions

View File

@@ -103,7 +103,7 @@ func manifestFromOCILayout(path string, platform *v1.Platform) (*Manifest, error
// try the containerd annotation if the org.opencontainers.image.ref.name is not a full name
subjectName = idxDescriptor.Annotations[containerd.AnnotationImageName]
if _, err := reference.ParseNamed(subjectName); err != nil {
return nil, fmt.Errorf("failed to parse subject name from annotations")
return nil, fmt.Errorf("failed to find subject name in annotations")
}
}

View File

@@ -76,12 +76,12 @@ func TestSubjectNameAnnotations(t *testing.T) {
}{
{name: "oci annotation", ociLayoutPath: test.UnsignedTestImage("..")},
{name: "containerd annotation", ociLayoutPath: filepath.Join("..", "test", "testdata", "containerd-subject-layout")},
{name: "missing subject name", ociLayoutPath: filepath.Join("..", "test", "testdata", "missing-subject-layout"), errorStr: "failed to parse subject name from annotations"},
{name: "missing subject name", ociLayoutPath: filepath.Join("..", "test", "testdata", "missing-subject-layout"), errorStr: "failed to find subject name in annotations"},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
spec, err := oci.ParseImageSpec(oci.LocalPrefix + tc.ociLayoutPath)
spec, err := oci.ParseImageSpec(oci.LocalPrefix+tc.ociLayoutPath, oci.WithPlatform("linux/arm64"))
require.NoError(t, err)
_, err = policy.CreateImageDetailsResolver(spec)
if tc.errorStr != "" {