(t *testing.T)
| 10 | ) |
| 11 | |
| 12 | func TestBuildLayerInfosForCopy(t *testing.T) { |
| 13 | manifestInfos := []manifest.LayerInfo{ |
| 14 | {BlobInfo: types.BlobInfo{Digest: "sha256:6a5a5368e0c2d3e5909184fa28ddfd56072e7ff3ee9a945876f7eee5896ef5bb", Size: -1}, EmptyLayer: false}, |
| 15 | {BlobInfo: types.BlobInfo{Digest: "sha256:a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4", Size: -1}, EmptyLayer: true}, |
| 16 | {BlobInfo: types.BlobInfo{Digest: "sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", Size: -1}, EmptyLayer: true}, |
| 17 | {BlobInfo: types.BlobInfo{Digest: "sha256:1bbf5d58d24c47512e234a5623474acf65ae00d4d1414272a893204f44cc680c", Size: -1}, EmptyLayer: false}, |
| 18 | {BlobInfo: types.BlobInfo{Digest: "sha256:5555555555555555555555555555555555555555555555555555555555555555", Size: -1}, EmptyLayer: true}, |
| 19 | } |
| 20 | physicalInfos := []types.BlobInfo{ |
| 21 | {Digest: "sha256:1111111111111111111111111111111111111111111111111111111111111111", Size: 111, MediaType: manifest.DockerV2Schema2LayerMediaType}, |
| 22 | {Digest: "sha256:2222222222222222222222222222222222222222222222222222222222222222", Size: 222, MediaType: manifest.DockerV2Schema2LayerMediaType}, |
| 23 | } |
| 24 | |
| 25 | // Success |
| 26 | res, err := buildLayerInfosForCopy(manifestInfos, physicalInfos) |
| 27 | require.NoError(t, err) |
| 28 | assert.Equal(t, []types.BlobInfo{ |
| 29 | {Digest: "sha256:1111111111111111111111111111111111111111111111111111111111111111", Size: 111, MediaType: manifest.DockerV2Schema2LayerMediaType}, |
| 30 | {Digest: "sha256:a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4", Size: 32}, |
| 31 | {Digest: "sha256:a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4", Size: 32}, |
| 32 | {Digest: "sha256:2222222222222222222222222222222222222222222222222222222222222222", Size: 222, MediaType: manifest.DockerV2Schema2LayerMediaType}, |
| 33 | {Digest: "sha256:a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4", Size: 32}, |
| 34 | }, res) |
| 35 | |
| 36 | // PhysicalInfos too short |
| 37 | _, err = buildLayerInfosForCopy(manifestInfos, physicalInfos[:len(physicalInfos)-1]) |
| 38 | assert.Error(t, err) |
| 39 | |
| 40 | // PhysicalInfos too long |
| 41 | _, err = buildLayerInfosForCopy(manifestInfos, append(physicalInfos, physicalInfos[0])) |
| 42 | assert.Error(t, err) |
| 43 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…