mirror of
https://github.com/actions/labeler.git
synced 2025-12-11 03:58:05 +00:00
Cleanup
This commit is contained in:
@@ -22,13 +22,16 @@ const configureInput = (
|
||||
mockInput: Partial<{
|
||||
'repo-token': string;
|
||||
'configuration-path': string;
|
||||
'sync-labels': boolean;
|
||||
dot: boolean;
|
||||
'sync-labels': string;
|
||||
dot: string;
|
||||
}>
|
||||
) => {
|
||||
jest
|
||||
.spyOn(core, 'getInput')
|
||||
.mockImplementation((name: string, ...opts) => mockInput[name]);
|
||||
jest
|
||||
.spyOn(core, 'getBooleanInput')
|
||||
.mockImplementation((name: string, ...opts) => mockInput[name] === 'true');
|
||||
};
|
||||
|
||||
afterAll(() => jest.restoreAllMocks());
|
||||
@@ -52,7 +55,7 @@ describe('run', () => {
|
||||
});
|
||||
|
||||
it('(with dot: true) adds labels to PRs that match our glob patterns', async () => {
|
||||
configureInput({dot: true});
|
||||
configureInput({dot: 'true'});
|
||||
usingLabelerConfigYaml('only_pdfs.yml');
|
||||
mockGitHubResponseChangedFiles('.foo.pdf');
|
||||
|
||||
@@ -80,7 +83,7 @@ describe('run', () => {
|
||||
});
|
||||
|
||||
it('(with dot: true) does not add labels to PRs that do not match our glob patterns', async () => {
|
||||
configureInput({dot: true});
|
||||
configureInput({dot: 'true'});
|
||||
usingLabelerConfigYaml('only_pdfs.yml');
|
||||
mockGitHubResponseChangedFiles('foo.txt');
|
||||
|
||||
@@ -91,20 +94,11 @@ describe('run', () => {
|
||||
});
|
||||
|
||||
it('(with sync-labels: true) it deletes preexisting PR labels that no longer match the glob pattern', async () => {
|
||||
const mockInput = {
|
||||
configureInput({
|
||||
'repo-token': 'foo',
|
||||
'configuration-path': 'bar',
|
||||
'sync-labels': 'true'
|
||||
};
|
||||
|
||||
jest
|
||||
.spyOn(core, 'getInput')
|
||||
.mockImplementation((name: string, ...opts) => mockInput[name]);
|
||||
jest
|
||||
.spyOn(core, 'getBooleanInput')
|
||||
.mockImplementation(
|
||||
(name: string, ...opts) => mockInput[name] === 'true'
|
||||
);
|
||||
});
|
||||
|
||||
usingLabelerConfigYaml('only_pdfs.yml');
|
||||
mockGitHubResponseChangedFiles('foo.txt');
|
||||
@@ -127,20 +121,11 @@ describe('run', () => {
|
||||
});
|
||||
|
||||
it('(with sync-labels: false) it issues no delete calls even when there are preexisting PR labels that no longer match the glob pattern', async () => {
|
||||
const mockInput = {
|
||||
configureInput({
|
||||
'repo-token': 'foo',
|
||||
'configuration-path': 'bar',
|
||||
'sync-labels': 'false'
|
||||
};
|
||||
|
||||
jest
|
||||
.spyOn(core, 'getInput')
|
||||
.mockImplementation((name: string, ...opts) => mockInput[name]);
|
||||
jest
|
||||
.spyOn(core, 'getBooleanInput')
|
||||
.mockImplementation(
|
||||
(name: string, ...opts) => mockInput[name] === 'true'
|
||||
);
|
||||
});
|
||||
|
||||
usingLabelerConfigYaml('only_pdfs.yml');
|
||||
mockGitHubResponseChangedFiles('foo.txt');
|
||||
|
||||
2
dist/index.js
vendored
2
dist/index.js
vendored
@@ -50,7 +50,7 @@ function run() {
|
||||
const token = core.getInput('repo-token');
|
||||
const configPath = core.getInput('configuration-path', { required: true });
|
||||
const syncLabels = core.getBooleanInput('sync-labels');
|
||||
const dot = !!core.getInput('dot', { required: false });
|
||||
const dot = !!core.getBooleanInput('dot', { required: false });
|
||||
const prNumber = getPrNumber();
|
||||
if (!prNumber) {
|
||||
core.info('Could not get pull request number from context, exiting');
|
||||
|
||||
@@ -16,7 +16,7 @@ export async function run() {
|
||||
const token = core.getInput('repo-token');
|
||||
const configPath = core.getInput('configuration-path', {required: true});
|
||||
const syncLabels = core.getBooleanInput('sync-labels');
|
||||
const dot = !!core.getInput('dot', {required: false});
|
||||
const dot = !!core.getBooleanInput('dot', {required: false});
|
||||
|
||||
const prNumber = getPrNumber();
|
||||
if (!prNumber) {
|
||||
|
||||
Reference in New Issue
Block a user