mirror of
https://github.com/actions/stale.git
synced 2025-12-11 12:37:27 +00:00
Revert "Merge pull request #586 from C0ZEN/feature/split-pr-and-issue-options"
This reverts commitdb699ab3b1, reversing changes made tob83d488cb9.
This commit is contained in:
@@ -9,7 +9,7 @@ import {generateIssue} from './functions/generate-issue';
|
||||
test('processing an issue with no label will make it stale and close it, if it is old enough only if days-before-close is set to 0', async () => {
|
||||
const opts: IIssuesProcessorOptions = {
|
||||
...DefaultProcessorOptions,
|
||||
daysBeforeIssueClose: 0
|
||||
daysBeforeClose: 0
|
||||
};
|
||||
const TestIssueList: Issue[] = [
|
||||
generateIssue(opts, 1, 'An issue with no label', '2020-01-01T17:00:00Z')
|
||||
@@ -33,7 +33,7 @@ test('processing an issue with no label and a start date as ECMAScript epoch in
|
||||
const january2000 = 946681200000;
|
||||
const opts: IIssuesProcessorOptions = {
|
||||
...DefaultProcessorOptions,
|
||||
daysBeforeIssueClose: 0,
|
||||
daysBeforeClose: 0,
|
||||
startDate: january2000.toString()
|
||||
};
|
||||
const TestIssueList: Issue[] = [
|
||||
@@ -64,7 +64,7 @@ test('processing an issue with no label and a start date as ECMAScript epoch in
|
||||
const january2021 = 1609455600000;
|
||||
const opts: IIssuesProcessorOptions = {
|
||||
...DefaultProcessorOptions,
|
||||
daysBeforeIssueClose: 0,
|
||||
daysBeforeClose: 0,
|
||||
startDate: january2021.toString()
|
||||
};
|
||||
const TestIssueList: Issue[] = [
|
||||
@@ -95,7 +95,7 @@ test('processing an issue with no label and a start date as ECMAScript epoch in
|
||||
const january2000 = 946681200000000;
|
||||
const opts: IIssuesProcessorOptions = {
|
||||
...DefaultProcessorOptions,
|
||||
daysBeforeIssueClose: 0,
|
||||
daysBeforeClose: 0,
|
||||
startDate: january2000.toString()
|
||||
};
|
||||
const TestIssueList: Issue[] = [
|
||||
@@ -126,7 +126,7 @@ test('processing an issue with no label and a start date as ECMAScript epoch in
|
||||
const january2021 = 1609455600000;
|
||||
const opts: IIssuesProcessorOptions = {
|
||||
...DefaultProcessorOptions,
|
||||
daysBeforeIssueClose: 0,
|
||||
daysBeforeClose: 0,
|
||||
startDate: january2021.toString()
|
||||
};
|
||||
const TestIssueList: Issue[] = [
|
||||
@@ -157,7 +157,7 @@ test('processing an issue with no label and a start date as ISO 8601 being befor
|
||||
const january2000 = '2000-01-01T00:00:00Z';
|
||||
const opts: IIssuesProcessorOptions = {
|
||||
...DefaultProcessorOptions,
|
||||
daysBeforeIssueClose: 0,
|
||||
daysBeforeClose: 0,
|
||||
startDate: january2000.toString()
|
||||
};
|
||||
const TestIssueList: Issue[] = [
|
||||
@@ -188,7 +188,7 @@ test('processing an issue with no label and a start date as ISO 8601 being after
|
||||
const january2021 = '2021-01-01T00:00:00Z';
|
||||
const opts: IIssuesProcessorOptions = {
|
||||
...DefaultProcessorOptions,
|
||||
daysBeforeIssueClose: 0,
|
||||
daysBeforeClose: 0,
|
||||
startDate: january2021.toString()
|
||||
};
|
||||
const TestIssueList: Issue[] = [
|
||||
@@ -219,7 +219,7 @@ test('processing an issue with no label and a start date as RFC 2822 being befor
|
||||
const january2000 = 'January 1, 2000 00:00:00';
|
||||
const opts: IIssuesProcessorOptions = {
|
||||
...DefaultProcessorOptions,
|
||||
daysBeforeIssueClose: 0,
|
||||
daysBeforeClose: 0,
|
||||
startDate: january2000.toString()
|
||||
};
|
||||
const TestIssueList: Issue[] = [
|
||||
@@ -250,7 +250,7 @@ test('processing an issue with no label and a start date as RFC 2822 being after
|
||||
const january2021 = 'January 1, 2021 00:00:00';
|
||||
const opts: IIssuesProcessorOptions = {
|
||||
...DefaultProcessorOptions,
|
||||
daysBeforeIssueClose: 0,
|
||||
daysBeforeClose: 0,
|
||||
startDate: january2021.toString()
|
||||
};
|
||||
const TestIssueList: Issue[] = [
|
||||
@@ -279,6 +279,7 @@ test('processing an issue with no label and a start date as RFC 2822 being after
|
||||
test('processing an issue with no label will make it stale and close it, if it is old enough only if days-before-close is set to > 0 and days-before-issue-close is set to 0', async () => {
|
||||
const opts: IIssuesProcessorOptions = {
|
||||
...DefaultProcessorOptions,
|
||||
daysBeforeClose: 1,
|
||||
daysBeforeIssueClose: 0
|
||||
};
|
||||
const TestIssueList: Issue[] = [
|
||||
@@ -299,10 +300,33 @@ test('processing an issue with no label will make it stale and close it, if it i
|
||||
expect(processor.deletedBranchIssues).toHaveLength(0);
|
||||
});
|
||||
|
||||
test('processing an issue with no label will make it stale and not close it, if it is old enough only if days-before-close is set to > 0 and days-before-issue-close is set to > 0', async () => {
|
||||
const opts: IIssuesProcessorOptions = {
|
||||
...DefaultProcessorOptions,
|
||||
daysBeforeClose: 1,
|
||||
daysBeforeIssueClose: 1
|
||||
};
|
||||
const TestIssueList: Issue[] = [
|
||||
generateIssue(opts, 1, 'An issue with no label', '2020-01-01T17:00:00Z')
|
||||
];
|
||||
const processor = new IssuesProcessorMock(
|
||||
opts,
|
||||
async p => (p === 1 ? TestIssueList : []),
|
||||
async () => [],
|
||||
async () => new Date().toDateString()
|
||||
);
|
||||
|
||||
// process our fake issue list
|
||||
await processor.processIssues(1);
|
||||
|
||||
expect(processor.staleIssues).toHaveLength(1);
|
||||
expect(processor.closedIssues).toHaveLength(0);
|
||||
});
|
||||
|
||||
test('processing an issue with no label will make it stale and not close it if days-before-close is set to > 0', async () => {
|
||||
const opts: IIssuesProcessorOptions = {
|
||||
...DefaultProcessorOptions,
|
||||
daysBeforeIssueClose: 15
|
||||
daysBeforeClose: 15
|
||||
};
|
||||
const TestIssueList: Issue[] = [
|
||||
generateIssue(opts, 1, 'An issue with no label', '2020-01-01T17:00:00Z')
|
||||
@@ -324,6 +348,7 @@ test('processing an issue with no label will make it stale and not close it if d
|
||||
test('processing an issue with no label will make it stale and not close it if days-before-close is set to -1 and days-before-issue-close is set to > 0', async () => {
|
||||
const opts: IIssuesProcessorOptions = {
|
||||
...DefaultProcessorOptions,
|
||||
daysBeforeClose: -1,
|
||||
daysBeforeIssueClose: 15
|
||||
};
|
||||
const TestIssueList: Issue[] = [
|
||||
@@ -347,7 +372,7 @@ test('processing an issue with no label will not make it stale if days-before-st
|
||||
const opts: IIssuesProcessorOptions = {
|
||||
...DefaultProcessorOptions,
|
||||
staleIssueMessage: '',
|
||||
daysBeforeIssueStale: -1
|
||||
daysBeforeStale: -1
|
||||
};
|
||||
const TestIssueList: Issue[] = [
|
||||
generateIssue(opts, 1, 'An issue with no label', '2020-01-01T17:00:00Z')
|
||||
@@ -370,6 +395,7 @@ test('processing an issue with no label will not make it stale if days-before-st
|
||||
const opts: IIssuesProcessorOptions = {
|
||||
...DefaultProcessorOptions,
|
||||
staleIssueMessage: '',
|
||||
daysBeforeStale: -1,
|
||||
daysBeforeIssueStale: -1
|
||||
};
|
||||
const TestIssueList: Issue[] = [
|
||||
@@ -419,7 +445,7 @@ test('processing an issue with no label will make it stale but not close it', as
|
||||
test('processing a stale issue will close it', async () => {
|
||||
const opts: IIssuesProcessorOptions = {
|
||||
...DefaultProcessorOptions,
|
||||
daysBeforeIssueClose: 30
|
||||
daysBeforeClose: 30
|
||||
};
|
||||
const TestIssueList: Issue[] = [
|
||||
generateIssue(
|
||||
@@ -509,7 +535,7 @@ test('processing a stale issue containing a slash in the label will close it', a
|
||||
test('processing a stale issue will close it when days-before-issue-stale override days-before-stale', async () => {
|
||||
const opts: IIssuesProcessorOptions = {
|
||||
...DefaultProcessorOptions,
|
||||
daysBeforeIssueClose: 30,
|
||||
daysBeforeClose: 30,
|
||||
daysBeforeIssueStale: 30
|
||||
};
|
||||
const TestIssueList: Issue[] = [
|
||||
@@ -540,7 +566,7 @@ test('processing a stale issue will close it when days-before-issue-stale overri
|
||||
test('processing a stale PR will close it', async () => {
|
||||
const opts: IIssuesProcessorOptions = {
|
||||
...DefaultProcessorOptions,
|
||||
daysBeforePrClose: 30
|
||||
daysBeforeClose: 30
|
||||
};
|
||||
const TestIssueList: Issue[] = [
|
||||
generateIssue(
|
||||
@@ -570,6 +596,7 @@ test('processing a stale PR will close it', async () => {
|
||||
test('processing a stale PR will close it when days-before-pr-stale override days-before-stale', async () => {
|
||||
const opts: IIssuesProcessorOptions = {
|
||||
...DefaultProcessorOptions,
|
||||
daysBeforeClose: 30,
|
||||
daysBeforePrClose: 30
|
||||
};
|
||||
const TestIssueList: Issue[] = [
|
||||
@@ -598,10 +625,9 @@ test('processing a stale PR will close it when days-before-pr-stale override day
|
||||
});
|
||||
|
||||
test('processing a stale issue will close it even if configured not to mark as stale', async () => {
|
||||
const opts: IIssuesProcessorOptions = {
|
||||
const opts = {
|
||||
...DefaultProcessorOptions,
|
||||
daysBeforeIssueStale: -1,
|
||||
daysBeforePrStale: -1,
|
||||
daysBeforeStale: -1,
|
||||
staleIssueMessage: ''
|
||||
};
|
||||
const TestIssueList: Issue[] = [
|
||||
@@ -630,10 +656,10 @@ test('processing a stale issue will close it even if configured not to mark as s
|
||||
});
|
||||
|
||||
test('processing a stale issue will close it even if configured not to mark as stale when days-before-issue-stale override days-before-stale', async () => {
|
||||
const opts: IIssuesProcessorOptions = {
|
||||
const opts = {
|
||||
...DefaultProcessorOptions,
|
||||
daysBeforeStale: 0,
|
||||
daysBeforeIssueStale: -1,
|
||||
daysBeforePrStale: 0,
|
||||
staleIssueMessage: ''
|
||||
};
|
||||
const TestIssueList: Issue[] = [
|
||||
@@ -662,10 +688,9 @@ test('processing a stale issue will close it even if configured not to mark as s
|
||||
});
|
||||
|
||||
test('processing a stale PR will close it even if configured not to mark as stale', async () => {
|
||||
const opts: IIssuesProcessorOptions = {
|
||||
const opts = {
|
||||
...DefaultProcessorOptions,
|
||||
daysBeforeIssueStale: -1,
|
||||
daysBeforePrStale: -1,
|
||||
daysBeforeStale: -1,
|
||||
stalePrMessage: ''
|
||||
};
|
||||
const TestIssueList: Issue[] = [
|
||||
@@ -694,9 +719,9 @@ test('processing a stale PR will close it even if configured not to mark as stal
|
||||
});
|
||||
|
||||
test('processing a stale PR will close it even if configured not to mark as stale when days-before-pr-stale override days-before-stale', async () => {
|
||||
const opts: IIssuesProcessorOptions = {
|
||||
const opts = {
|
||||
...DefaultProcessorOptions,
|
||||
daysBeforeIssueStale: 0,
|
||||
daysBeforeStale: 0,
|
||||
daysBeforePrStale: -1,
|
||||
stalePrMessage: ''
|
||||
};
|
||||
@@ -940,7 +965,7 @@ test('stale locked prs will not be closed', async () => {
|
||||
|
||||
test('exempt issue labels will not be marked stale', async () => {
|
||||
expect.assertions(3);
|
||||
const opts: IIssuesProcessorOptions = {...DefaultProcessorOptions};
|
||||
const opts = {...DefaultProcessorOptions};
|
||||
opts.exemptIssueLabels = 'Exempt';
|
||||
const TestIssueList: Issue[] = [
|
||||
generateIssue(
|
||||
@@ -969,7 +994,7 @@ test('exempt issue labels will not be marked stale', async () => {
|
||||
});
|
||||
|
||||
test('exempt issue labels will not be marked stale (multi issue label with spaces)', async () => {
|
||||
const opts: IIssuesProcessorOptions = {...DefaultProcessorOptions};
|
||||
const opts = {...DefaultProcessorOptions};
|
||||
opts.exemptIssueLabels = 'Exempt, Cool, None';
|
||||
const TestIssueList: Issue[] = [
|
||||
generateIssue(
|
||||
@@ -997,7 +1022,7 @@ test('exempt issue labels will not be marked stale (multi issue label with space
|
||||
});
|
||||
|
||||
test('exempt issue labels will not be marked stale (multi issue label)', async () => {
|
||||
const opts: IIssuesProcessorOptions = {...DefaultProcessorOptions};
|
||||
const opts = {...DefaultProcessorOptions};
|
||||
opts.exemptIssueLabels = 'Exempt,Cool,None';
|
||||
const TestIssueList: Issue[] = [
|
||||
generateIssue(
|
||||
@@ -1026,7 +1051,7 @@ test('exempt issue labels will not be marked stale (multi issue label)', async (
|
||||
});
|
||||
|
||||
test('exempt pr labels will not be marked stale', async () => {
|
||||
const opts: IIssuesProcessorOptions = {...DefaultProcessorOptions};
|
||||
const opts = {...DefaultProcessorOptions};
|
||||
opts.exemptIssueLabels = 'Cool';
|
||||
const TestIssueList: Issue[] = [
|
||||
generateIssue(
|
||||
@@ -1071,7 +1096,7 @@ test('exempt pr labels will not be marked stale', async () => {
|
||||
|
||||
test('exempt issue labels will not be marked stale and will remove the existing stale label', async () => {
|
||||
expect.assertions(3);
|
||||
const opts: IIssuesProcessorOptions = {...DefaultProcessorOptions};
|
||||
const opts = {...DefaultProcessorOptions};
|
||||
opts.exemptIssueLabels = 'Exempt';
|
||||
const TestIssueList: Issue[] = [
|
||||
generateIssue(
|
||||
@@ -1108,9 +1133,8 @@ test('exempt issue labels will not be marked stale and will remove the existing
|
||||
});
|
||||
|
||||
test('stale issues should not be closed if days is set to -1', async () => {
|
||||
const opts: IIssuesProcessorOptions = {...DefaultProcessorOptions};
|
||||
opts.daysBeforeIssueClose = -1;
|
||||
opts.daysBeforePrClose = -1;
|
||||
const opts = {...DefaultProcessorOptions};
|
||||
opts.daysBeforeClose = -1;
|
||||
const TestIssueList: Issue[] = [
|
||||
generateIssue(
|
||||
opts,
|
||||
@@ -1155,11 +1179,7 @@ test('stale issues should not be closed if days is set to -1', async () => {
|
||||
});
|
||||
|
||||
test('stale label should be removed if a comment was added to a stale issue', async () => {
|
||||
const opts: IIssuesProcessorOptions = {
|
||||
...DefaultProcessorOptions,
|
||||
removeIssueStaleWhenUpdated: true,
|
||||
removePrStaleWhenUpdated: true
|
||||
};
|
||||
const opts = {...DefaultProcessorOptions, removeStaleWhenUpdated: true};
|
||||
const TestIssueList: Issue[] = [
|
||||
generateIssue(
|
||||
opts,
|
||||
@@ -1196,10 +1216,9 @@ test('stale label should be removed if a comment was added to a stale issue', as
|
||||
|
||||
test('when the option "labelsToAddWhenUnstale" is set, the labels should be added when unstale', async () => {
|
||||
expect.assertions(4);
|
||||
const opts: IIssuesProcessorOptions = {
|
||||
const opts = {
|
||||
...DefaultProcessorOptions,
|
||||
removeIssueStaleWhenUpdated: true,
|
||||
removePrStaleWhenUpdated: true,
|
||||
removeStaleWhenUpdated: true,
|
||||
labelsToAddWhenUnstale: 'test'
|
||||
};
|
||||
const TestIssueList: Issue[] = [
|
||||
@@ -1240,11 +1259,7 @@ test('when the option "labelsToAddWhenUnstale" is set, the labels should be adde
|
||||
});
|
||||
|
||||
test('stale label should not be removed if a comment was added by the bot (and the issue should be closed)', async () => {
|
||||
const opts: IIssuesProcessorOptions = {
|
||||
...DefaultProcessorOptions,
|
||||
removeIssueStaleWhenUpdated: true,
|
||||
removePrStaleWhenUpdated: true
|
||||
};
|
||||
const opts = {...DefaultProcessorOptions, removeStaleWhenUpdated: true};
|
||||
github.context.actor = 'abot';
|
||||
const TestIssueList: Issue[] = [
|
||||
generateIssue(
|
||||
@@ -1283,8 +1298,7 @@ test('stale label should not be removed if a comment was added by the bot (and t
|
||||
test('stale label containing a space should be removed if a comment was added to a stale issue', async () => {
|
||||
const opts: IIssuesProcessorOptions = {
|
||||
...DefaultProcessorOptions,
|
||||
removeIssueStaleWhenUpdated: true,
|
||||
removePrStaleWhenUpdated: true,
|
||||
removeStaleWhenUpdated: true,
|
||||
staleIssueLabel: 'stat: stale'
|
||||
};
|
||||
const TestIssueList: Issue[] = [
|
||||
@@ -1314,9 +1328,9 @@ test('stale label containing a space should be removed if a comment was added to
|
||||
});
|
||||
|
||||
test('stale issues should not be closed until after the closed number of days', async () => {
|
||||
const opts: IIssuesProcessorOptions = {...DefaultProcessorOptions};
|
||||
opts.daysBeforeIssueStale = 5; // stale after 5 days
|
||||
opts.daysBeforeIssueClose = 1; // closes after 6 days
|
||||
const opts = {...DefaultProcessorOptions};
|
||||
opts.daysBeforeStale = 5; // stale after 5 days
|
||||
opts.daysBeforeClose = 1; // closes after 6 days
|
||||
const lastUpdate = new Date();
|
||||
lastUpdate.setDate(lastUpdate.getDate() - 5);
|
||||
const TestIssueList: Issue[] = [
|
||||
@@ -1345,9 +1359,9 @@ test('stale issues should not be closed until after the closed number of days',
|
||||
});
|
||||
|
||||
test('stale issues should be closed if the closed nubmer of days (additive) is also passed', async () => {
|
||||
const opts: IIssuesProcessorOptions = {...DefaultProcessorOptions};
|
||||
opts.daysBeforeIssueStale = 5; // stale after 5 days
|
||||
opts.daysBeforeIssueClose = 1; // closes after 6 days
|
||||
const opts = {...DefaultProcessorOptions};
|
||||
opts.daysBeforeStale = 5; // stale after 5 days
|
||||
opts.daysBeforeClose = 1; // closes after 6 days
|
||||
const lastUpdate = new Date();
|
||||
lastUpdate.setDate(lastUpdate.getDate() - 7);
|
||||
const TestIssueList: Issue[] = [
|
||||
@@ -1377,9 +1391,9 @@ test('stale issues should be closed if the closed nubmer of days (additive) is a
|
||||
});
|
||||
|
||||
test('stale issues should not be closed until after the closed number of days (long)', async () => {
|
||||
const opts: IIssuesProcessorOptions = {...DefaultProcessorOptions};
|
||||
opts.daysBeforeIssueStale = 5; // stale after 5 days
|
||||
opts.daysBeforeIssueClose = 20; // closes after 25 days
|
||||
const opts = {...DefaultProcessorOptions};
|
||||
opts.daysBeforeStale = 5; // stale after 5 days
|
||||
opts.daysBeforeClose = 20; // closes after 25 days
|
||||
const lastUpdate = new Date();
|
||||
lastUpdate.setDate(lastUpdate.getDate() - 10);
|
||||
const TestIssueList: Issue[] = [
|
||||
@@ -1408,9 +1422,9 @@ test('stale issues should not be closed until after the closed number of days (l
|
||||
});
|
||||
|
||||
test('skips stale message on issues when stale-issue-message is empty', async () => {
|
||||
const opts: IIssuesProcessorOptions = {...DefaultProcessorOptions};
|
||||
opts.daysBeforeIssueStale = 5; // stale after 5 days
|
||||
opts.daysBeforeIssueClose = 20; // closes after 25 days
|
||||
const opts = {...DefaultProcessorOptions};
|
||||
opts.daysBeforeStale = 5; // stale after 5 days
|
||||
opts.daysBeforeClose = 20; // closes after 25 days
|
||||
opts.staleIssueMessage = '';
|
||||
const lastUpdate = new Date();
|
||||
lastUpdate.setDate(lastUpdate.getDate() - 10);
|
||||
@@ -1452,9 +1466,9 @@ test('skips stale message on issues when stale-issue-message is empty', async ()
|
||||
});
|
||||
|
||||
test('send stale message on issues when stale-issue-message is not empty', async () => {
|
||||
const opts: IIssuesProcessorOptions = {...DefaultProcessorOptions};
|
||||
opts.daysBeforeIssueStale = 5; // stale after 5 days
|
||||
opts.daysBeforeIssueClose = 20; // closes after 25 days
|
||||
const opts = {...DefaultProcessorOptions};
|
||||
opts.daysBeforeStale = 5; // stale after 5 days
|
||||
opts.daysBeforeClose = 20; // closes after 25 days
|
||||
opts.staleIssueMessage = 'dummy issue message';
|
||||
const lastUpdate = new Date();
|
||||
lastUpdate.setDate(lastUpdate.getDate() - 10);
|
||||
@@ -1496,9 +1510,9 @@ test('send stale message on issues when stale-issue-message is not empty', async
|
||||
});
|
||||
|
||||
test('skips stale message on prs when stale-pr-message is empty', async () => {
|
||||
const opts: IIssuesProcessorOptions = {...DefaultProcessorOptions};
|
||||
opts.daysBeforeIssueStale = 5; // stale after 5 days
|
||||
opts.daysBeforeIssueClose = 20; // closes after 25 days
|
||||
const opts = {...DefaultProcessorOptions};
|
||||
opts.daysBeforeStale = 5; // stale after 5 days
|
||||
opts.daysBeforeClose = 20; // closes after 25 days
|
||||
opts.stalePrMessage = '';
|
||||
const lastUpdate = new Date();
|
||||
lastUpdate.setDate(lastUpdate.getDate() - 10);
|
||||
@@ -1540,9 +1554,9 @@ test('skips stale message on prs when stale-pr-message is empty', async () => {
|
||||
});
|
||||
|
||||
test('send stale message on prs when stale-pr-message is not empty', async () => {
|
||||
const opts: IIssuesProcessorOptions = {...DefaultProcessorOptions};
|
||||
opts.daysBeforeIssueStale = 5; // stale after 5 days
|
||||
opts.daysBeforeIssueClose = 20; // closes after 25 days
|
||||
const opts = {...DefaultProcessorOptions};
|
||||
opts.daysBeforeStale = 5; // stale after 5 days
|
||||
opts.daysBeforeClose = 20; // closes after 25 days
|
||||
opts.stalePrMessage = 'dummy pr message';
|
||||
const lastUpdate = new Date();
|
||||
lastUpdate.setDate(lastUpdate.getDate() - 10);
|
||||
@@ -1584,10 +1598,7 @@ test('send stale message on prs when stale-pr-message is not empty', async () =>
|
||||
});
|
||||
|
||||
test('git branch is deleted when option is enabled', async () => {
|
||||
const opts: IIssuesProcessorOptions = {
|
||||
...DefaultProcessorOptions,
|
||||
deleteBranch: true
|
||||
};
|
||||
const opts = {...DefaultProcessorOptions, deleteBranch: true};
|
||||
const isPullRequest = true;
|
||||
const TestIssueList: Issue[] = [
|
||||
generateIssue(
|
||||
@@ -1616,10 +1627,7 @@ test('git branch is deleted when option is enabled', async () => {
|
||||
});
|
||||
|
||||
test('git branch is not deleted when issue is not pull request', async () => {
|
||||
const opts: IIssuesProcessorOptions = {
|
||||
...DefaultProcessorOptions,
|
||||
deleteBranch: true
|
||||
};
|
||||
const opts = {...DefaultProcessorOptions, deleteBranch: true};
|
||||
const isPullRequest = false;
|
||||
const TestIssueList: Issue[] = [
|
||||
generateIssue(
|
||||
@@ -1680,8 +1688,8 @@ test('an issue without a milestone will be marked as stale', async () => {
|
||||
|
||||
test('an issue without an exempted milestone will be marked as stale', async () => {
|
||||
expect.assertions(3);
|
||||
const opts: IIssuesProcessorOptions = {...DefaultProcessorOptions};
|
||||
opts.exemptIssueMilestones = 'Milestone1';
|
||||
const opts = {...DefaultProcessorOptions};
|
||||
opts.exemptMilestones = 'Milestone1';
|
||||
const TestIssueList: Issue[] = [
|
||||
generateIssue(
|
||||
opts,
|
||||
@@ -1713,8 +1721,8 @@ test('an issue without an exempted milestone will be marked as stale', async ()
|
||||
|
||||
test('an issue with an exempted milestone will not be marked as stale', async () => {
|
||||
expect.assertions(3);
|
||||
const opts: IIssuesProcessorOptions = {...DefaultProcessorOptions};
|
||||
opts.exemptIssueMilestones = 'Milestone1';
|
||||
const opts = {...DefaultProcessorOptions};
|
||||
opts.exemptMilestones = 'Milestone1';
|
||||
const TestIssueList: Issue[] = [
|
||||
generateIssue(
|
||||
opts,
|
||||
@@ -1746,8 +1754,8 @@ test('an issue with an exempted milestone will not be marked as stale', async ()
|
||||
|
||||
test('an issue with an exempted milestone will not be marked as stale (multi milestones with spaces)', async () => {
|
||||
expect.assertions(3);
|
||||
const opts: IIssuesProcessorOptions = {...DefaultProcessorOptions};
|
||||
opts.exemptIssueMilestones = 'Milestone1, Milestone2';
|
||||
const opts = {...DefaultProcessorOptions};
|
||||
opts.exemptMilestones = 'Milestone1, Milestone2';
|
||||
const TestIssueList: Issue[] = [
|
||||
generateIssue(
|
||||
opts,
|
||||
@@ -1779,8 +1787,8 @@ test('an issue with an exempted milestone will not be marked as stale (multi mil
|
||||
|
||||
test('an issue with an exempted milestone will not be marked as stale (multi milestones without spaces)', async () => {
|
||||
expect.assertions(3);
|
||||
const opts: IIssuesProcessorOptions = {...DefaultProcessorOptions};
|
||||
opts.exemptIssueMilestones = 'Milestone1,Milestone2';
|
||||
const opts = {...DefaultProcessorOptions};
|
||||
opts.exemptMilestones = 'Milestone1,Milestone2';
|
||||
const TestIssueList: Issue[] = [
|
||||
generateIssue(
|
||||
opts,
|
||||
@@ -1810,10 +1818,113 @@ test('an issue with an exempted milestone will not be marked as stale (multi mil
|
||||
expect(processor.removedLabelIssues.length).toStrictEqual(0);
|
||||
});
|
||||
|
||||
test('an issue with an exempted milestone but without an exempted issue milestone will not be marked as stale', async () => {
|
||||
expect.assertions(3);
|
||||
const opts = {...DefaultProcessorOptions};
|
||||
opts.exemptMilestones = 'Milestone1';
|
||||
opts.exemptIssueMilestones = '';
|
||||
const TestIssueList: Issue[] = [
|
||||
generateIssue(
|
||||
opts,
|
||||
1,
|
||||
'My first issue',
|
||||
'2020-01-01T17:00:00Z',
|
||||
'2020-01-01T17:00:00Z',
|
||||
false,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
'Milestone1'
|
||||
)
|
||||
];
|
||||
const processor = new IssuesProcessorMock(
|
||||
opts,
|
||||
async p => (p === 1 ? TestIssueList : []),
|
||||
async () => [],
|
||||
async () => new Date().toDateString()
|
||||
);
|
||||
|
||||
// process our fake issue list
|
||||
await processor.processIssues(1);
|
||||
|
||||
expect(processor.staleIssues.length).toStrictEqual(0);
|
||||
expect(processor.closedIssues.length).toStrictEqual(0);
|
||||
expect(processor.removedLabelIssues.length).toStrictEqual(0);
|
||||
});
|
||||
|
||||
test('an issue with an exempted milestone but with another exempted issue milestone will be marked as stale', async () => {
|
||||
expect.assertions(3);
|
||||
const opts = {...DefaultProcessorOptions};
|
||||
opts.exemptMilestones = 'Milestone1';
|
||||
opts.exemptIssueMilestones = 'Milestone2';
|
||||
const TestIssueList: Issue[] = [
|
||||
generateIssue(
|
||||
opts,
|
||||
1,
|
||||
'My first issue',
|
||||
'2020-01-01T17:00:00Z',
|
||||
'2020-01-01T17:00:00Z',
|
||||
false,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
'Milestone1'
|
||||
)
|
||||
];
|
||||
const processor = new IssuesProcessorMock(
|
||||
opts,
|
||||
async p => (p === 1 ? TestIssueList : []),
|
||||
async () => [],
|
||||
async () => new Date().toDateString()
|
||||
);
|
||||
|
||||
// process our fake issue list
|
||||
await processor.processIssues(1);
|
||||
|
||||
expect(processor.staleIssues.length).toStrictEqual(1);
|
||||
expect(processor.closedIssues.length).toStrictEqual(0);
|
||||
expect(processor.removedLabelIssues.length).toStrictEqual(0);
|
||||
});
|
||||
|
||||
test('an issue with an exempted milestone and with an exempted issue milestone will not be marked as stale', async () => {
|
||||
expect.assertions(3);
|
||||
const opts = {...DefaultProcessorOptions};
|
||||
opts.exemptMilestones = 'Milestone1';
|
||||
opts.exemptIssueMilestones = 'Milestone1';
|
||||
const TestIssueList: Issue[] = [
|
||||
generateIssue(
|
||||
opts,
|
||||
1,
|
||||
'My first issue',
|
||||
'2020-01-01T17:00:00Z',
|
||||
'2020-01-01T17:00:00Z',
|
||||
false,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
'Milestone1'
|
||||
)
|
||||
];
|
||||
const processor = new IssuesProcessorMock(
|
||||
opts,
|
||||
async p => (p === 1 ? TestIssueList : []),
|
||||
async () => [],
|
||||
async () => new Date().toDateString()
|
||||
);
|
||||
|
||||
// process our fake issue list
|
||||
await processor.processIssues(1);
|
||||
|
||||
expect(processor.staleIssues.length).toStrictEqual(0);
|
||||
expect(processor.closedIssues.length).toStrictEqual(0);
|
||||
expect(processor.removedLabelIssues.length).toStrictEqual(0);
|
||||
});
|
||||
|
||||
test('processing an issue opened since 2 days and with the option "daysBeforeIssueStale" at 3 will not make it stale', async () => {
|
||||
expect.assertions(2);
|
||||
const opts: IIssuesProcessorOptions = {
|
||||
...DefaultProcessorOptions,
|
||||
daysBeforeStale: 10,
|
||||
daysBeforeIssueStale: 3
|
||||
};
|
||||
const issueDate = new Date();
|
||||
@@ -1839,6 +1950,7 @@ test('processing an issue opened since 2 days and with the option "daysBeforeIss
|
||||
expect.assertions(2);
|
||||
const opts: IIssuesProcessorOptions = {
|
||||
...DefaultProcessorOptions,
|
||||
daysBeforeStale: 10,
|
||||
daysBeforeIssueStale: 2
|
||||
};
|
||||
const issueDate = new Date();
|
||||
@@ -1864,6 +1976,7 @@ test('processing an issue opened since 2 days and with the option "daysBeforeIss
|
||||
expect.assertions(2);
|
||||
const opts: IIssuesProcessorOptions = {
|
||||
...DefaultProcessorOptions,
|
||||
daysBeforeStale: 10,
|
||||
daysBeforeIssueStale: 1
|
||||
};
|
||||
const issueDate = new Date();
|
||||
@@ -1889,7 +2002,7 @@ test('processing a pull request opened since 2 days and with the option "daysBef
|
||||
expect.assertions(2);
|
||||
const opts: IIssuesProcessorOptions = {
|
||||
...DefaultProcessorOptions,
|
||||
daysBeforeIssueStale: 10,
|
||||
daysBeforeStale: 10,
|
||||
daysBeforePrStale: 3
|
||||
};
|
||||
const issueDate = new Date();
|
||||
@@ -1922,7 +2035,7 @@ test('processing a pull request opened since 2 days and with the option "daysBef
|
||||
expect.assertions(2);
|
||||
const opts: IIssuesProcessorOptions = {
|
||||
...DefaultProcessorOptions,
|
||||
daysBeforeIssueStale: 10,
|
||||
daysBeforeStale: 10,
|
||||
daysBeforePrStale: 2
|
||||
};
|
||||
const issueDate = new Date();
|
||||
@@ -1955,7 +2068,7 @@ test('processing a pull request opened since 2 days and with the option "daysBef
|
||||
expect.assertions(2);
|
||||
const opts: IIssuesProcessorOptions = {
|
||||
...DefaultProcessorOptions,
|
||||
daysBeforeIssueStale: 10,
|
||||
daysBeforeStale: 10,
|
||||
daysBeforePrStale: 1
|
||||
};
|
||||
const issueDate = new Date();
|
||||
@@ -2094,11 +2207,10 @@ test('processing an issue stale since less than the daysBeforeStale with a stale
|
||||
const opts: IIssuesProcessorOptions = {
|
||||
...DefaultProcessorOptions,
|
||||
staleIssueLabel: 'stale-label',
|
||||
daysBeforeIssueStale: 30,
|
||||
daysBeforeIssueClose: 7,
|
||||
daysBeforeStale: 30,
|
||||
daysBeforeClose: 7,
|
||||
closeIssueMessage: 'close message',
|
||||
removeIssueStaleWhenUpdated: false,
|
||||
removePrStaleWhenUpdated: false
|
||||
removeStaleWhenUpdated: false
|
||||
};
|
||||
const now: Date = new Date();
|
||||
const updatedAt: Date = new Date(now.setDate(now.getDate() - 9));
|
||||
@@ -2136,11 +2248,10 @@ test('processing an issue stale since less than the daysBeforeStale without a st
|
||||
const opts: IIssuesProcessorOptions = {
|
||||
...DefaultProcessorOptions,
|
||||
staleIssueLabel: 'stale-label',
|
||||
daysBeforeIssueStale: 30,
|
||||
daysBeforeIssueClose: 7,
|
||||
daysBeforeStale: 30,
|
||||
daysBeforeClose: 7,
|
||||
closeIssueMessage: 'close message',
|
||||
removeIssueStaleWhenUpdated: false,
|
||||
removePrStaleWhenUpdated: false
|
||||
removeStaleWhenUpdated: false
|
||||
};
|
||||
const now: Date = new Date();
|
||||
const updatedAt: Date = new Date(now.setDate(now.getDate() - 9));
|
||||
@@ -2177,7 +2288,7 @@ test('processing a pull request to be stale with the "stalePrMessage" option set
|
||||
const opts: IIssuesProcessorOptions = {
|
||||
...DefaultProcessorOptions,
|
||||
stalePrMessage: 'This PR is stale',
|
||||
daysBeforeIssueStale: 10,
|
||||
daysBeforeStale: 10,
|
||||
daysBeforePrStale: 1
|
||||
};
|
||||
const issueDate = new Date();
|
||||
@@ -2212,7 +2323,7 @@ test('processing a pull request to be stale with the "stalePrMessage" option set
|
||||
const opts: IIssuesProcessorOptions = {
|
||||
...DefaultProcessorOptions,
|
||||
stalePrMessage: '',
|
||||
daysBeforeIssueStale: 10,
|
||||
daysBeforeStale: 10,
|
||||
daysBeforePrStale: 1
|
||||
};
|
||||
const issueDate = new Date();
|
||||
|
||||
Reference in New Issue
Block a user