leave shared object unchanged

This commit is contained in:
boxofyellow
2024-01-25 09:58:31 -08:00
committed by ddivad195
parent df5639170c
commit 0ba67aaf7a
+12 -2
View File
@@ -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
}