From c06282fe294e7a652fa093a55542ed8f5726c11d Mon Sep 17 00:00:00 2001 From: boxofyellow <54955040+boxofyellow@users.noreply.github.com> Date: Thu, 25 Jan 2024 10:54:19 -0800 Subject: [PATCH] make main.test.ts test data more varied --- __tests__/main.test.ts | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/__tests__/main.test.ts b/__tests__/main.test.ts index 13d9d3a..eb12a52 100644 --- a/__tests__/main.test.ts +++ b/__tests__/main.test.ts @@ -69,7 +69,7 @@ describe('action', () => { it('fails if event is not a release', async () => { // Mock the environment - process.env.GITHUB_REPOSITORY = 'test/test' + process.env.GITHUB_REPOSITORY = 'test-org/test-repo' github.context.eventName = 'push' // Run the action @@ -83,7 +83,7 @@ describe('action', () => { it('fails if release tag is not a valid semantic version', async () => { // Mock the environment - process.env.GITHUB_REPOSITORY = 'test/test' + process.env.GITHUB_REPOSITORY = 'test-org/test-repo' github.context.eventName = 'release' github.context.payload = { release: { @@ -103,12 +103,12 @@ describe('action', () => { it('fails if multiple paths are provided and staging files fails', async () => { // Mock the environment - process.env.GITHUB_REPOSITORY = 'test/test' + process.env.GITHUB_REPOSITORY = 'test-org/test-repo' github.context.eventName = 'release' github.context.payload = { release: { id: '123', - tag_name: 'v1.0.0' + tag_name: 'v1.2.3' } } getInputMock.mockImplementation((name: string) => { @@ -135,12 +135,12 @@ describe('action', () => { it('fails if an error is thrown from dependent code', async () => { // Mock the environment - process.env.GITHUB_REPOSITORY = 'test/test' + process.env.GITHUB_REPOSITORY = 'test-org/test-repo' github.context.eventName = 'release' github.context.payload = { release: { id: '123', - tag_name: 'v1.0.0' + tag_name: 'v1.2.3' } } getInputMock.mockImplementation((name: string) => { @@ -172,22 +172,22 @@ describe('action', () => { }) it('successfully uploads if the release tag is a semver without v prefix', async () => { - await testHappyPath('1.0.0', 'test') + await testHappyPath('1.2.3', 'test') }) it('successfully uploads if the release tag is a semver with v prefix', async () => { - await testHappyPath('v1.0.0', 'test') + await testHappyPath('v1.2.3', 'test') }) it('successfully uploads if multiple paths are provided', async () => { - await testHappyPath('v1.0.0', 'test test2') + await testHappyPath('v1.2.3', 'test test2') }) }) // Test that main successfully uploads and returns the manifest & package URL async function testHappyPath(version: string, path: string): Promise { // Mock the environment - process.env.GITHUB_REPOSITORY = 'test/test' + process.env.GITHUB_REPOSITORY = 'test-org/test-repo' github.context.eventName = 'release' github.context.payload = { release: { @@ -228,7 +228,7 @@ async function testHappyPath(version: string, path: string): Promise { }) publishOCIArtifactMock.mockImplementation(() => { - return new URL('https://ghcr.io/v2/test/test:1.0.0') + return new URL('https://ghcr.io/v2/test-org/test-repo:1.2.3') }) // Run the action @@ -239,7 +239,7 @@ async function testHappyPath(version: string, path: string): Promise { // Check manifest is in output expect(setOutputMock).toHaveBeenCalledWith( 'package-url', - 'https://ghcr.io/v2/test/test:1.0.0' + 'https://ghcr.io/v2/test-org/test-repo:1.2.3' ) expect(setOutputMock).toHaveBeenCalledWith( 'package-manifest',