split mega param into several different ones

Signed-off-by: Meredith Lancaster <[email protected]>
This commit is contained in:
Meredith Lancaster
2025-12-09 11:37:04 -08:00
parent 056c217a52
commit d75223fd4a
3 changed files with 94 additions and 98 deletions
@@ -6,17 +6,13 @@ describe('createStorageRecord', () => {
const token = 'token'
const headers = {'X-GitHub-Foo': 'true'}
const options = {
artifactOptions: {
name: 'my-lib',
version: '1.0.0',
digest: `sha256:${'a'.repeat(64)}`
},
packageRegistryOptions: {
registryUrl: 'https://my-registry.org'
},
token,
writeOptions: {headers}
const artifactOptions = {
name: 'my-lib',
version: '1.0.0',
digest: `sha256:${'a'.repeat(64)}`
}
const packageRegistryOptions = {
registryUrl: 'https://my-registry.org'
}
const mockAgent = new MockAgent()
@@ -52,7 +48,7 @@ describe('createStorageRecord', () => {
})
it('persists the storage record', async () => {
await expect(createStorageRecord(options)).resolves.toEqual([123, 456])
await expect(createStorageRecord(artifactOptions, packageRegistryOptions, token, undefined, headers)).resolves.toEqual([123, 456])
})
})
@@ -76,10 +72,13 @@ describe('createStorageRecord', () => {
it('throws an error', async () => {
await expect(
createStorageRecord({
...options,
writeOptions: {retry: 0}
})
createStorageRecord(
artifactOptions,
packageRegistryOptions,
token,
0,
headers
)
).rejects.toThrow(/oops/)
})
})
@@ -94,8 +93,8 @@ describe('createStorageRecord', () => {
method: 'POST',
headers: {authorization: `token ${token}`},
body: JSON.stringify({
...options.artifactOptions,
registry_url: options.packageRegistryOptions.registryUrl
...artifactOptions,
registry_url: packageRegistryOptions.registryUrl
})
})
.reply(500, 'oops')
@@ -107,8 +106,8 @@ describe('createStorageRecord', () => {
method: 'POST',
headers: {authorization: `token ${token}`},
body: JSON.stringify({
...options.artifactOptions,
registry_url: options.packageRegistryOptions.registryUrl
...artifactOptions,
registry_url: packageRegistryOptions.registryUrl
})
})
.reply(200, {storage_records: [{id: 123}, {id: 456}]})
@@ -117,10 +116,13 @@ describe('createStorageRecord', () => {
it('persists the storage record', async () => {
await expect(
createStorageRecord({
...options,
writeOptions: {}
})
createStorageRecord(
artifactOptions,
packageRegistryOptions,
token,
undefined,
headers
)
).resolves.toEqual([123, 456])
})
})