|
|
|
|
@@ -31,7 +31,7 @@ function generateIssue(
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const DefaultProcessorOptions: IssueProcessorOptions = {
|
|
|
|
|
const DefaultProcessorOptions: IssueProcessorOptions = Object.freeze({
|
|
|
|
|
repoToken: 'none',
|
|
|
|
|
staleIssueMessage: 'This issue is stale',
|
|
|
|
|
stalePrMessage: 'This PR is stale',
|
|
|
|
|
@@ -48,7 +48,7 @@ const DefaultProcessorOptions: IssueProcessorOptions = {
|
|
|
|
|
debugOnly: true,
|
|
|
|
|
removeStaleWhenUpdated: false,
|
|
|
|
|
ascending: false
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('empty issue list results in 1 operation', async () => {
|
|
|
|
|
const processor = new IssueProcessor(
|
|
|
|
|
@@ -109,6 +109,31 @@ test('processing an issue with no label will make it stale and not close it if d
|
|
|
|
|
expect(processor.closedIssues.length).toEqual(0);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('processing an issue with no label will not make it stale if days-before-stale is set to -1', async () => {
|
|
|
|
|
const TestIssueList: Issue[] = [
|
|
|
|
|
generateIssue(1, 'An issue with no label', '2020-01-01T17:00:00Z')
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
const opts = {
|
|
|
|
|
...DefaultProcessorOptions,
|
|
|
|
|
staleIssueMessage: '',
|
|
|
|
|
daysBeforeStale: -1
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const processor = new IssueProcessor(
|
|
|
|
|
opts,
|
|
|
|
|
async p => (p == 1 ? TestIssueList : []),
|
|
|
|
|
async (num, dt) => [],
|
|
|
|
|
async (issue, label) => new Date().toDateString()
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// process our fake issue list
|
|
|
|
|
await processor.processIssues(1);
|
|
|
|
|
|
|
|
|
|
expect(processor.staleIssues.length).toEqual(0);
|
|
|
|
|
expect(processor.closedIssues.length).toEqual(0);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('processing an issue with no label will make it stale but not close it', async () => {
|
|
|
|
|
// issue should be from 2 days ago so it will be
|
|
|
|
|
// stale but not close-able, based on default settings
|
|
|
|
|
@@ -183,6 +208,60 @@ test('processing a stale PR will close it', async () => {
|
|
|
|
|
expect(processor.closedIssues.length).toEqual(1);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('processing a stale issue will close it even if configured not to mark as stale', async () => {
|
|
|
|
|
const TestIssueList: Issue[] = [
|
|
|
|
|
generateIssue(1, 'An issue with no label', '2020-01-01T17:00:00Z', false, [
|
|
|
|
|
'Stale'
|
|
|
|
|
])
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
const opts = {
|
|
|
|
|
...DefaultProcessorOptions,
|
|
|
|
|
daysBeforeStale: -1,
|
|
|
|
|
staleIssueMessage: ''
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const processor = new IssueProcessor(
|
|
|
|
|
opts,
|
|
|
|
|
async p => (p == 1 ? TestIssueList : []),
|
|
|
|
|
async (num, dt) => [],
|
|
|
|
|
async (issue, label) => new Date().toDateString()
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// process our fake issue list
|
|
|
|
|
await processor.processIssues(1);
|
|
|
|
|
|
|
|
|
|
expect(processor.staleIssues.length).toEqual(0);
|
|
|
|
|
expect(processor.closedIssues.length).toEqual(1);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('processing a stale PR will close it even if configured not to mark as stale', async () => {
|
|
|
|
|
const TestIssueList: Issue[] = [
|
|
|
|
|
generateIssue(1, 'An issue with no label', '2020-01-01T17:00:00Z', true, [
|
|
|
|
|
'Stale'
|
|
|
|
|
])
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
const opts = {
|
|
|
|
|
...DefaultProcessorOptions,
|
|
|
|
|
daysBeforeStale: -1,
|
|
|
|
|
stalePrMessage: ''
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const processor = new IssueProcessor(
|
|
|
|
|
opts,
|
|
|
|
|
async p => (p == 1 ? TestIssueList : []),
|
|
|
|
|
async (num, dt) => [],
|
|
|
|
|
async (issue, label) => new Date().toDateString()
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// process our fake issue list
|
|
|
|
|
await processor.processIssues(1);
|
|
|
|
|
|
|
|
|
|
expect(processor.staleIssues.length).toEqual(0);
|
|
|
|
|
expect(processor.closedIssues.length).toEqual(1);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('closed issues will not be marked stale', async () => {
|
|
|
|
|
const TestIssueList: Issue[] = [
|
|
|
|
|
generateIssue(
|
|
|
|
|
@@ -517,7 +596,7 @@ test('stale label should be removed if a comment was added to a stale issue', as
|
|
|
|
|
)
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
const opts = DefaultProcessorOptions;
|
|
|
|
|
const opts = {...DefaultProcessorOptions};
|
|
|
|
|
opts.removeStaleWhenUpdated = true;
|
|
|
|
|
|
|
|
|
|
const processor = new IssueProcessor(
|
|
|
|
|
@@ -547,7 +626,7 @@ test('stale label should not be removed if a comment was added by the bot (and t
|
|
|
|
|
)
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
const opts = DefaultProcessorOptions;
|
|
|
|
|
const opts = {...DefaultProcessorOptions};
|
|
|
|
|
opts.removeStaleWhenUpdated = true;
|
|
|
|
|
|
|
|
|
|
const processor = new IssueProcessor(
|
|
|
|
|
@@ -577,7 +656,7 @@ test('stale issues should not be closed until after the closed number of days',
|
|
|
|
|
)
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
const opts = DefaultProcessorOptions;
|
|
|
|
|
const opts = {...DefaultProcessorOptions};
|
|
|
|
|
opts.daysBeforeStale = 5; // stale after 5 days
|
|
|
|
|
opts.daysBeforeClose = 1; // closes after 6 days
|
|
|
|
|
|
|
|
|
|
@@ -609,7 +688,7 @@ test('stale issues should be closed if the closed nubmer of days (additive) is a
|
|
|
|
|
)
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
const opts = DefaultProcessorOptions;
|
|
|
|
|
const opts = {...DefaultProcessorOptions};
|
|
|
|
|
opts.daysBeforeStale = 5; // stale after 5 days
|
|
|
|
|
opts.daysBeforeClose = 1; // closes after 6 days
|
|
|
|
|
|
|
|
|
|
@@ -640,7 +719,7 @@ test('stale issues should not be closed until after the closed number of days (l
|
|
|
|
|
)
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
const opts = DefaultProcessorOptions;
|
|
|
|
|
const opts = {...DefaultProcessorOptions};
|
|
|
|
|
opts.daysBeforeStale = 5; // stale after 5 days
|
|
|
|
|
opts.daysBeforeClose = 20; // closes after 25 days
|
|
|
|
|
|
|
|
|
|
|