Skip to content

Commit

Permalink
Allow specifying the config fixture in newOCI1ImageSource
Browse files Browse the repository at this point in the history
Should not change (test) behavior for now.

Signed-off-by: Miloslav Trmač <[email protected]>
  • Loading branch information
mtrmac committed Aug 4, 2023
1 parent d72dd62 commit 0ced545
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions internal/image/oci_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ func TestManifestOCI1OCIConfig(t *testing.T) {
err = json.Unmarshal(configJSON, &expectedConfig)
require.NoError(t, err)

originalSrc := newOCI1ImageSource(t, "httpd:latest")
originalSrc := newOCI1ImageSource(t, "oci1-config.json", "httpd:latest")
for _, m := range []genericManifest{
manifestOCI1FromFixture(t, originalSrc, "oci1.json"),
manifestOCI1FromComponentsLikeFixture(configJSON),
Expand Down Expand Up @@ -357,8 +357,8 @@ func (OCIis *oci1ImageSource) Reference() types.ImageReference {
return refImageReferenceMock{ref: OCIis.ref}
}

func newOCI1ImageSource(t *testing.T, dockerRef string) *oci1ImageSource {
realConfigJSON, err := os.ReadFile("fixtures/oci1-config.json")
func newOCI1ImageSource(t *testing.T, configFixture string, dockerRef string) *oci1ImageSource {
realConfigJSON, err := os.ReadFile(filepath.Join("fixtures", configFixture))
require.NoError(t, err)

ref, err := reference.ParseNormalizedNamed(dockerRef)
Expand All @@ -376,7 +376,7 @@ func newOCI1ImageSource(t *testing.T, dockerRef string) *oci1ImageSource {
}

func TestManifestOCI1UpdatedImage(t *testing.T) {
originalSrc := newOCI1ImageSource(t, "httpd:latest")
originalSrc := newOCI1ImageSource(t, "oci1-config.json", "httpd:latest")
original := manifestOCI1FromFixture(t, originalSrc, "oci1.json")

// LayerInfos:
Expand Down Expand Up @@ -437,7 +437,7 @@ func TestManifestOCI1UpdatedImage(t *testing.T) {
}

func TestManifestOCI1ConvertToManifestSchema1(t *testing.T) {
originalSrc := newOCI1ImageSource(t, "httpd-copy:latest")
originalSrc := newOCI1ImageSource(t, "oci1-config.json", "httpd-copy:latest")
original := manifestOCI1FromFixture(t, originalSrc, "oci1.json")
memoryDest := &memoryImageDest{ref: originalSrc.ref}
res, err := original.UpdatedImage(context.Background(), types.ManifestUpdateOptions{
Expand Down Expand Up @@ -506,7 +506,7 @@ func TestManifestOCI1ConvertToManifestSchema1(t *testing.T) {
}

func TestConvertToManifestSchema2(t *testing.T) {
originalSrc := newOCI1ImageSource(t, "httpd-copy:latest")
originalSrc := newOCI1ImageSource(t, "oci1-config.json", "httpd-copy:latest")
original := manifestOCI1FromFixture(t, originalSrc, "oci1.json")
res, err := original.UpdatedImage(context.Background(), types.ManifestUpdateOptions{
ManifestMIMEType: manifest.DockerV2Schema2MediaType,
Expand Down Expand Up @@ -534,7 +534,7 @@ func TestConvertToManifestSchema2(t *testing.T) {
}

func TestConvertToManifestSchema2AllMediaTypes(t *testing.T) {
originalSrc := newOCI1ImageSource(t, "httpd-copy:latest")
originalSrc := newOCI1ImageSource(t, "oci1-config.json", "httpd-copy:latest")
original := manifestOCI1FromFixture(t, originalSrc, "oci1-all-media-types.json")
_, err := original.UpdatedImage(context.Background(), types.ManifestUpdateOptions{
ManifestMIMEType: manifest.DockerV2Schema2MediaType,
Expand All @@ -543,7 +543,7 @@ func TestConvertToManifestSchema2AllMediaTypes(t *testing.T) {
}

func TestConvertToV2S2WithInvalidMIMEType(t *testing.T) {
originalSrc := newOCI1ImageSource(t, "httpd-copy:latest")
originalSrc := newOCI1ImageSource(t, "oci1-config.json", "httpd-copy:latest")
manifest, err := os.ReadFile(filepath.Join("fixtures", "oci1-invalid-media-type.json"))
require.NoError(t, err)

Expand Down

0 comments on commit 0ced545

Please sign in to comment.