mirror of
https://github.com/actions/toolkit.git
synced 2026-08-21 00:00:16 +02:00
fix test and function calls
Signed-off-by: Meredith Lancaster <[email protected]>
This commit is contained in:
@@ -6,13 +6,18 @@ describe('createStorageRecord', () => {
|
|||||||
const attestation = {foo: 'bar '}
|
const attestation = {foo: 'bar '}
|
||||||
const token = 'token'
|
const token = 'token'
|
||||||
const headers = {'X-GitHub-Foo': 'true'}
|
const headers = {'X-GitHub-Foo': 'true'}
|
||||||
const artifactOptions = {
|
|
||||||
name: "my-lib",
|
const options = {
|
||||||
version: "1.0.0",
|
artifactOptions: {
|
||||||
digest: "sha256:1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
|
name: "my-lib",
|
||||||
}
|
version: "1.0.0",
|
||||||
const registryOptions = {
|
digest: "sha256:1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
|
||||||
registryUrl: 'https://my-registry.org',
|
},
|
||||||
|
packageRegistryOptions: {
|
||||||
|
registryUrl: 'https://my-registry.org',
|
||||||
|
},
|
||||||
|
token,
|
||||||
|
writeOptions: {headers},
|
||||||
}
|
}
|
||||||
|
|
||||||
const mockAgent = new MockAgent()
|
const mockAgent = new MockAgent()
|
||||||
@@ -49,12 +54,7 @@ describe('createStorageRecord', () => {
|
|||||||
|
|
||||||
it('persists the storage record', async () => {
|
it('persists the storage record', async () => {
|
||||||
await expect(
|
await expect(
|
||||||
createStorageRecord({
|
createStorageRecord(options)
|
||||||
artifactOptions: artifactOptions,
|
|
||||||
packageRegistryOptions: registryOptions,
|
|
||||||
token,
|
|
||||||
writeOptions: {headers},
|
|
||||||
})
|
|
||||||
).resolves.toEqual(['123', '456'])
|
).resolves.toEqual(['123', '456'])
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -80,9 +80,7 @@ describe('createStorageRecord', () => {
|
|||||||
it('throws an error', async () => {
|
it('throws an error', async () => {
|
||||||
await expect(
|
await expect(
|
||||||
createStorageRecord({
|
createStorageRecord({
|
||||||
artifactOptions: artifactOptions,
|
...options,
|
||||||
packageRegistryOptions: registryOptions,
|
|
||||||
token,
|
|
||||||
writeOptions: {retry: 0},
|
writeOptions: {retry: 0},
|
||||||
})
|
})
|
||||||
).rejects.toThrow(/oops/)
|
).rejects.toThrow(/oops/)
|
||||||
@@ -95,32 +93,34 @@ describe('createStorageRecord', () => {
|
|||||||
|
|
||||||
pool
|
pool
|
||||||
.intercept({
|
.intercept({
|
||||||
path: '/repos/foo/bar/attestations',
|
path: '/orgs/foo/artifacts/metadata/storage-record',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {authorization: `token ${token}`},
|
headers: {authorization: `token ${token}`},
|
||||||
body: JSON.stringify({...artifactOptions, registry_url: registryOptions.registryUrl})
|
body: JSON.stringify({
|
||||||
|
...options.artifactOptions,
|
||||||
|
registry_url: options.packageRegistryOptions.registryUrl,
|
||||||
|
})
|
||||||
})
|
})
|
||||||
.reply(500, 'oops')
|
.reply(500, 'oops')
|
||||||
.times(1)
|
.times(1)
|
||||||
|
|
||||||
pool
|
pool
|
||||||
.intercept({
|
.intercept({
|
||||||
path: '/repos/foo/bar/attestations',
|
path: '/orgs/foo/artifacts/metadata/storage-record',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {authorization: `token ${token}`},
|
headers: {authorization: `token ${token}`},
|
||||||
body: JSON.stringify({})
|
body: JSON.stringify({
|
||||||
|
...options.artifactOptions,
|
||||||
|
registry_url: options.packageRegistryOptions.registryUrl,
|
||||||
|
})
|
||||||
})
|
})
|
||||||
.reply(201, {storage_records: [{id: '123'}, {id: '456'}]})
|
.reply(201, {storage_records: [{id: '123'}, {id: '456'}]})
|
||||||
.times(1)
|
.times(1)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('persists the attestation', async () => {
|
it('persists the attestation', async () => {
|
||||||
const { registryUrl, ...rest } = registryOptions
|
|
||||||
await expect(createStorageRecord({
|
await expect(createStorageRecord({
|
||||||
...artifactOptions,
|
...options,
|
||||||
...rest,
|
|
||||||
registry_url: registryUrl,
|
|
||||||
token,
|
|
||||||
writeOptions: {},
|
writeOptions: {},
|
||||||
})).resolves.toEqual(['123', '456'])
|
})).resolves.toEqual(['123', '456'])
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ export async function createStorageRecord(options: StorageRecordOptions): Promis
|
|||||||
const response = await octokit.request(CREATE_STORAGE_RECORD_REQUEST, {
|
const response = await octokit.request(CREATE_STORAGE_RECORD_REQUEST, {
|
||||||
owner: github.context.repo.owner,
|
owner: github.context.repo.owner,
|
||||||
headers: options.writeOptions.headers,
|
headers: options.writeOptions.headers,
|
||||||
...buildRequestParams(options.artifactOptions, options.packageRegistryOptions),
|
...buildRequestParams(options),
|
||||||
})
|
})
|
||||||
|
|
||||||
const data =
|
const data =
|
||||||
|
|||||||
Reference in New Issue
Block a user