leave shared object unchanged
This commit is contained in:
@@ -484,9 +484,13 @@ describe('publishOCIArtifact', () => {
|
||||
})
|
||||
|
||||
it('throws an error if one of the layers has the wrong media type', async () => {
|
||||
const modifiedTestManifest = testManifest
|
||||
const modifiedTestManifest = { ...testManifest } // This is _NOT_ a deep clone
|
||||
modifiedTestManifest.layers = cloneLayers(modifiedTestManifest.layers)
|
||||
modifiedTestManifest.layers[0].mediaType = 'application/json'
|
||||
|
||||
// just checking to make sure we are not changing the shared object
|
||||
expect(modifiedTestManifest.layers[0].mediaType).not.toEqual(testManifest.layers[0].mediaType)
|
||||
|
||||
await expect(
|
||||
publishOCIArtifact(
|
||||
token,
|
||||
@@ -496,7 +500,7 @@ describe('publishOCIArtifact', () => {
|
||||
semver,
|
||||
zipFile,
|
||||
tarFile,
|
||||
testManifest
|
||||
modifiedTestManifest
|
||||
)
|
||||
).rejects.toThrow('Unknown media type application/json')
|
||||
})
|
||||
@@ -534,3 +538,9 @@ function validateRequestConfig(status: number, url: string, config: any): void {
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
function cloneLayers(layers: ociContainer.Layer[]) : ociContainer.Layer[] {
|
||||
const result : ociContainer.Layer[] = [];
|
||||
layers.forEach(val => result.push({ ... val })) // this is _NOT_ a deep clone
|
||||
return result
|
||||
}
|
||||
Reference in New Issue
Block a user