make main.test.ts test data more varied
This commit is contained in:
+12
-12
@@ -69,7 +69,7 @@ describe('action', () => {
|
|||||||
|
|
||||||
it('fails if event is not a release', async () => {
|
it('fails if event is not a release', async () => {
|
||||||
// Mock the environment
|
// Mock the environment
|
||||||
process.env.GITHUB_REPOSITORY = 'test/test'
|
process.env.GITHUB_REPOSITORY = 'test-org/test-repo'
|
||||||
github.context.eventName = 'push'
|
github.context.eventName = 'push'
|
||||||
|
|
||||||
// Run the action
|
// Run the action
|
||||||
@@ -83,7 +83,7 @@ describe('action', () => {
|
|||||||
|
|
||||||
it('fails if release tag is not a valid semantic version', async () => {
|
it('fails if release tag is not a valid semantic version', async () => {
|
||||||
// Mock the environment
|
// Mock the environment
|
||||||
process.env.GITHUB_REPOSITORY = 'test/test'
|
process.env.GITHUB_REPOSITORY = 'test-org/test-repo'
|
||||||
github.context.eventName = 'release'
|
github.context.eventName = 'release'
|
||||||
github.context.payload = {
|
github.context.payload = {
|
||||||
release: {
|
release: {
|
||||||
@@ -103,12 +103,12 @@ describe('action', () => {
|
|||||||
|
|
||||||
it('fails if multiple paths are provided and staging files fails', async () => {
|
it('fails if multiple paths are provided and staging files fails', async () => {
|
||||||
// Mock the environment
|
// Mock the environment
|
||||||
process.env.GITHUB_REPOSITORY = 'test/test'
|
process.env.GITHUB_REPOSITORY = 'test-org/test-repo'
|
||||||
github.context.eventName = 'release'
|
github.context.eventName = 'release'
|
||||||
github.context.payload = {
|
github.context.payload = {
|
||||||
release: {
|
release: {
|
||||||
id: '123',
|
id: '123',
|
||||||
tag_name: 'v1.0.0'
|
tag_name: 'v1.2.3'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
getInputMock.mockImplementation((name: string) => {
|
getInputMock.mockImplementation((name: string) => {
|
||||||
@@ -135,12 +135,12 @@ describe('action', () => {
|
|||||||
|
|
||||||
it('fails if an error is thrown from dependent code', async () => {
|
it('fails if an error is thrown from dependent code', async () => {
|
||||||
// Mock the environment
|
// Mock the environment
|
||||||
process.env.GITHUB_REPOSITORY = 'test/test'
|
process.env.GITHUB_REPOSITORY = 'test-org/test-repo'
|
||||||
github.context.eventName = 'release'
|
github.context.eventName = 'release'
|
||||||
github.context.payload = {
|
github.context.payload = {
|
||||||
release: {
|
release: {
|
||||||
id: '123',
|
id: '123',
|
||||||
tag_name: 'v1.0.0'
|
tag_name: 'v1.2.3'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
getInputMock.mockImplementation((name: string) => {
|
getInputMock.mockImplementation((name: string) => {
|
||||||
@@ -172,22 +172,22 @@ describe('action', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('successfully uploads if the release tag is a semver without v prefix', async () => {
|
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 () => {
|
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 () => {
|
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
|
// Test that main successfully uploads and returns the manifest & package URL
|
||||||
async function testHappyPath(version: string, path: string): Promise<void> {
|
async function testHappyPath(version: string, path: string): Promise<void> {
|
||||||
// Mock the environment
|
// Mock the environment
|
||||||
process.env.GITHUB_REPOSITORY = 'test/test'
|
process.env.GITHUB_REPOSITORY = 'test-org/test-repo'
|
||||||
github.context.eventName = 'release'
|
github.context.eventName = 'release'
|
||||||
github.context.payload = {
|
github.context.payload = {
|
||||||
release: {
|
release: {
|
||||||
@@ -228,7 +228,7 @@ async function testHappyPath(version: string, path: string): Promise<void> {
|
|||||||
})
|
})
|
||||||
|
|
||||||
publishOCIArtifactMock.mockImplementation(() => {
|
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
|
// Run the action
|
||||||
@@ -239,7 +239,7 @@ async function testHappyPath(version: string, path: string): Promise<void> {
|
|||||||
// Check manifest is in output
|
// Check manifest is in output
|
||||||
expect(setOutputMock).toHaveBeenCalledWith(
|
expect(setOutputMock).toHaveBeenCalledWith(
|
||||||
'package-url',
|
'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(
|
expect(setOutputMock).toHaveBeenCalledWith(
|
||||||
'package-manifest',
|
'package-manifest',
|
||||||
|
|||||||
Reference in New Issue
Block a user