Skip to content

Commit

Permalink
fix: correct reading of sync-labels input
Browse files Browse the repository at this point in the history
  • Loading branch information
MaksimZhukov committed May 24, 2023
1 parent e1fcf6f commit 26342ba
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
14 changes: 12 additions & 2 deletions __tests__/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,17 @@ describe('run', () => {
const mockInput = {
'repo-token': 'foo',
'configuration-path': 'bar',
'sync-labels': true
'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');
Expand All @@ -93,12 +98,17 @@ describe('run', () => {
const mockInput = {
'repo-token': 'foo',
'configuration-path': 'bar',
'sync-labels': false
'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');
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ function run() {
try {
const token = core.getInput('repo-token');
const configPath = core.getInput('configuration-path', { required: true });
const syncLabels = !!core.getInput('sync-labels', { required: false });
const syncLabels = core.getBooleanInput('sync-labels');
const prNumber = getPrNumber();
if (!prNumber) {
core.info('Could not get pull request number from context, exiting');
Expand Down
2 changes: 1 addition & 1 deletion src/labeler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export async function run() {
try {
const token = core.getInput('repo-token');
const configPath = core.getInput('configuration-path', {required: true});
const syncLabels = !!core.getInput('sync-labels', {required: false});
const syncLabels = core.getBooleanInput('sync-labels');

const prNumber = getPrNumber();
if (!prNumber) {
Expand Down

0 comments on commit 26342ba

Please sign in to comment.