From 22fac850a26e6c00eb20cb84072c013945d13a36 Mon Sep 17 00:00:00 2001 From: Niek Palm Date: Wed, 22 Dec 2021 09:48:20 +0100 Subject: [PATCH] Alter test data for pre-relases, add test case for empty response --- .../runner-binaries-syncer/src/syncer/syncer.test.ts | 12 ++++++++++-- .../test/resources/github-list-releases.json | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/modules/runner-binaries-syncer/lambdas/runner-binaries-syncer/src/syncer/syncer.test.ts b/modules/runner-binaries-syncer/lambdas/runner-binaries-syncer/src/syncer/syncer.test.ts index d506c7f88f..8bf377db08 100644 --- a/modules/runner-binaries-syncer/lambdas/runner-binaries-syncer/src/syncer/syncer.test.ts +++ b/modules/runner-binaries-syncer/lambdas/runner-binaries-syncer/src/syncer/syncer.test.ts @@ -62,7 +62,7 @@ describe('Synchronize action distribution.', () => { mockS3.getObjectTagging.mockImplementation(() => { return { promise() { - return Promise.resolve({ TagSet: [{ Key: 'name', Value: 'actions-runner-linux-x64-2.286.0.tar.gz' }] }); + return Promise.resolve({ TagSet: [{ Key: 'name', Value: 'actions-runner-linux-x64-2.285.1.tar.gz' }] }); }, }; }); @@ -136,7 +136,7 @@ describe('Synchronize action distribution.', () => { }); expect(mockS3.upload).toBeCalledTimes(1); const s3JsonBody = mockS3.upload.mock.calls[0][0]; - expect(s3JsonBody['Tagging']).toEqual('name=actions-runner-linux-x64-2.286.0.tar.gz'); + expect(s3JsonBody['Tagging']).toEqual('name=actions-runner-linux-x64-2.285.1.tar.gz'); }); it('Distribution should update to release if there are no pre-releases.', async () => { @@ -273,6 +273,14 @@ describe('No release assets found.', () => { await expect(sync()).rejects.toThrow(errorMessage); }); + + it('Empty asset list.', async () => { + mockOctokit.repos.listReleases.mockImplementation(() => ({ + data: [], + })); + + await expect(sync()).rejects.toThrow(errorMessage); + }); }); describe('Invalid config', () => { diff --git a/modules/runner-binaries-syncer/lambdas/runner-binaries-syncer/test/resources/github-list-releases.json b/modules/runner-binaries-syncer/lambdas/runner-binaries-syncer/test/resources/github-list-releases.json index f9e530ca99..e8a409645b 100644 --- a/modules/runner-binaries-syncer/lambdas/runner-binaries-syncer/test/resources/github-list-releases.json +++ b/modules/runner-binaries-syncer/lambdas/runner-binaries-syncer/test/resources/github-list-releases.json @@ -30,7 +30,7 @@ "target_commitish": "f1ddeb0d06bdbe3182a4f01c44ef622ec0c13437", "name": "v2.286.0", "draft": false, - "prerelease": false, + "prerelease": true, "created_at": "2021-12-21T15:51:03Z", "published_at": "2021-12-21T16:09:06Z", "assets": [