mirror of
https://github.com/apache/superset.git
synced 2026-04-16 22:55:52 +00:00
build: inline external Github Actions to unblock CI (#12241)
* build: inline cached-dependencies to unblock CI * Run E2E on pull_request on;y * Inline all external actions * Checkout needed for internal actions Also fixes pre-commit * Add missing files
This commit is contained in:
89
.github/actions/file-changes-action/src/tests/main.test.ts
vendored
Normal file
89
.github/actions/file-changes-action/src/tests/main.test.ts
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
import {Env, getTestEvents, getTestFiles, p} from './mocks/env'
|
||||
|
||||
let env: Env
|
||||
|
||||
describe('Testing main.ts...', () => {
|
||||
describe.each(p.testEvents)('...with %s event...', event => {
|
||||
/**
|
||||
* @function run
|
||||
*/
|
||||
describe('...with function run...', () => {
|
||||
describe.each(getTestEvents(p.getFormatExtInputs, 'push'))(
|
||||
'...with fileOutput %s...',
|
||||
(fileOutputName, fileOutputInput, fileOutputExpected) => {
|
||||
describe.each(getTestEvents(p.getFormatExtInputs, 'push'))(
|
||||
'...with output %o...',
|
||||
(outputName, outputInput, outputExpected) => {
|
||||
describe.each(getTestEvents(p.mainInputs, event))(
|
||||
'...with %s event inputs mocked...',
|
||||
(eventName, eventInput, eventExpected) => {
|
||||
beforeEach(() => {
|
||||
env = new Env(
|
||||
{},
|
||||
{
|
||||
githubRepo: 'trilom/file-changes-action',
|
||||
githubToken: 'TestToken',
|
||||
output: outputInput,
|
||||
fileOutput: fileOutputInput,
|
||||
...eventInput,
|
||||
mock: 'true'
|
||||
},
|
||||
event
|
||||
)
|
||||
})
|
||||
afterEach(() => {
|
||||
process.env = env.envStart
|
||||
jest.resetModules()
|
||||
jest.unmock('@actions/core')
|
||||
jest.unmock('@actions/github')
|
||||
jest.unmock('../InputHelper')
|
||||
jest.unmock('../FilesHelper')
|
||||
jest.unmock('../GithubHelper')
|
||||
})
|
||||
it('...mocked', async () => {
|
||||
const githubHelper = require('../GithubHelper')
|
||||
const filesHelper = require('../FilesHelper')
|
||||
githubHelper.getChangedFiles = jest.fn(
|
||||
() => getTestFiles().files
|
||||
)
|
||||
filesHelper.writeOutput = jest.fn(() => {})
|
||||
filesHelper.writeFiles = jest.fn(() => {})
|
||||
await expect(require('../main').run()).resolves.toBe(
|
||||
undefined
|
||||
)
|
||||
expect(githubHelper.getChangedFiles).toBeCalled()
|
||||
expect(filesHelper.writeOutput).toBeCalled()
|
||||
expect(filesHelper.writeFiles).toBeCalled()
|
||||
})
|
||||
it.each(getTestEvents(p.mainErrorInputs, 'push'))(
|
||||
'...throws error for mocked function %s...',
|
||||
async (f, e, expected) => {
|
||||
const inputHelper = require('../InputHelper')
|
||||
let thrown = false
|
||||
inputHelper.getInputs = jest.fn(() => {
|
||||
thrown = true
|
||||
throw new Error(e)
|
||||
})
|
||||
await expect(
|
||||
require('../main').run()
|
||||
).rejects.toThrowError(
|
||||
new Error(
|
||||
JSON.stringify({
|
||||
name: 'Error',
|
||||
message: 'Error',
|
||||
from: f
|
||||
})
|
||||
)
|
||||
)
|
||||
expect(inputHelper.getInputs).toHaveBeenCalledTimes(1)
|
||||
}
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user