From d1f9584cda66ff4509437966e843a1bc43348ad3 Mon Sep 17 00:00:00 2001 From: Meredith Lancaster Date: Mon, 8 Dec 2025 15:33:01 -0800 Subject: [PATCH] fix test calls Signed-off-by: Meredith Lancaster --- .../attest/__tests__/artifactMetadata.test.ts | 20 ++++++++++--------- packages/attest/src/artifactMetadata.ts | 16 +-------------- packages/attest/src/index.ts | 2 +- 3 files changed, 13 insertions(+), 25 deletions(-) diff --git a/packages/attest/__tests__/artifactMetadata.test.ts b/packages/attest/__tests__/artifactMetadata.test.ts index ab63c3f1..b3cf6542 100644 --- a/packages/attest/__tests__/artifactMetadata.test.ts +++ b/packages/attest/__tests__/artifactMetadata.test.ts @@ -6,12 +6,12 @@ describe('createStorageRecord', () => { const attestation = {foo: 'bar '} const token = 'token' const headers = {'X-GitHub-Foo': 'true'} - const artifactParams = { + const artifactOptions = { name: "my-lib", version: "1.0.0", digest: "sha256:1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef", } - const registryParams = { + const registryOptions = { registryUrl: 'https://my-registry.org', } @@ -50,8 +50,8 @@ describe('createStorageRecord', () => { it('persists the storage record', async () => { await expect( createStorageRecord({ - artifactOptions: artifactParams, - packageRegistryOptions: registryParams, + artifactOptions: artifactOptions, + packageRegistryOptions: registryOptions, token, writeOptions: {headers}, }) @@ -80,8 +80,8 @@ describe('createStorageRecord', () => { it('throws an error', async () => { await expect( createStorageRecord({ - artifactOptions: artifactParams, - packageRegistryOptions: registryParams, + artifactOptions: artifactOptions, + packageRegistryOptions: registryOptions, token, writeOptions: {retry: 0}, }) @@ -98,7 +98,7 @@ describe('createStorageRecord', () => { path: '/repos/foo/bar/attestations', method: 'POST', headers: {authorization: `token ${token}`}, - body: JSON.stringify({...artifactParams, registry_url: registryParams.registryUrl}) + body: JSON.stringify({...artifactOptions, registry_url: registryOptions.registryUrl}) }) .reply(500, 'oops') .times(1) @@ -115,9 +115,11 @@ describe('createStorageRecord', () => { }) it('persists the attestation', async () => { + const { registryUrl, ...rest } = registryOptions await expect(createStorageRecord({ - artifactOptions: artifactParams, - packageRegistryOptions: registryParams, + ...artifactOptions, + ...rest, + registry_url: registryUrl, token, writeOptions: {}, })).resolves.toEqual(['123', '456']) diff --git a/packages/attest/src/artifactMetadata.ts b/packages/attest/src/artifactMetadata.ts index 5e4bf10f..26c4fc4a 100644 --- a/packages/attest/src/artifactMetadata.ts +++ b/packages/attest/src/artifactMetadata.ts @@ -44,10 +44,7 @@ export type StorageRecordOptions = { /** * Writes a storage record on behalf of an artifact that has been attested - * @param artifactParams - parameters for the artifact. - * @param packageRegistryParams - parameters for the package registry. - * @param token - The GitHub token for authentication. - * @param options - Optional parameters for the write operation. + * @param StorageRecordOptions - parameters for the storage record API request. * @returns The ID of the storage record. * @throws Error if the storage record fails to persist. */ @@ -73,14 +70,3 @@ export async function createStorageRecord(options: StorageRecordOptions): Promis throw new Error(`Failed to persist storage record: ${message}`) } } - -const buildRequestParams = (artifactParams: ArtifactParams, registryParams: PackageRegistryParams) => { - const { registryUrl, artifactUrl, ...rest } = registryParams - return { - ...artifactParams, - ...rest, - // rename parameters to match API expectations - artifact_url: artifactUrl, - registry_url: registryUrl, - } -} diff --git a/packages/attest/src/index.ts b/packages/attest/src/index.ts index 54846dbf..78384d32 100644 --- a/packages/attest/src/index.ts +++ b/packages/attest/src/index.ts @@ -1,4 +1,4 @@ -export {createStorageRecord} from '.artifactMetadata' +export {createStorageRecord} from './artifactMetadata' export {AttestOptions, attest} from './attest' export { AttestProvenanceOptions,