mirror of
https://github.com/actions/stale.git
synced 2025-12-10 03:57:04 +00:00
Remove labels on stale (#959)
This commit is contained in:
@@ -47,6 +47,7 @@ export const DefaultProcessorOptions: IIssuesProcessorOptions = Object.freeze({
|
||||
exemptAllIssueAssignees: undefined,
|
||||
exemptAllPrAssignees: undefined,
|
||||
enableStatistics: true,
|
||||
labelsToRemoveWhenStale: '',
|
||||
labelsToRemoveWhenUnstale: '',
|
||||
labelsToAddWhenUnstale: '',
|
||||
ignoreUpdates: false,
|
||||
|
||||
@@ -1220,6 +1220,48 @@ test('when the option "labelsToAddWhenUnstale" is set, the labels should be adde
|
||||
expect(processor.addedLabelIssues).toHaveLength(1);
|
||||
});
|
||||
|
||||
test('when the option "labelsToRemoveWhenStale" is set, the labels should be removed when stale', async () => {
|
||||
expect.assertions(3);
|
||||
const opts = {
|
||||
...DefaultProcessorOptions,
|
||||
removeStaleWhenUpdated: true,
|
||||
labelsToRemoveWhenStale: 'test'
|
||||
};
|
||||
const TestIssueList: Issue[] = [
|
||||
generateIssue(
|
||||
opts,
|
||||
1,
|
||||
'An issue that should have labels removed to it when stale',
|
||||
'2020-01-01T17:00:00Z',
|
||||
'2020-01-01T17:00:00Z',
|
||||
false,
|
||||
['Stale', 'test']
|
||||
)
|
||||
];
|
||||
const processor = new IssuesProcessorMock(
|
||||
opts,
|
||||
async p => (p === 1 ? TestIssueList : []),
|
||||
async () => [
|
||||
{
|
||||
user: {
|
||||
login: 'notme',
|
||||
type: 'User'
|
||||
},
|
||||
body: 'Body'
|
||||
}
|
||||
], // return a fake comment to indicate there was an update
|
||||
async () => new Date().toDateString()
|
||||
);
|
||||
|
||||
// process our fake issue list
|
||||
await processor.processIssues(1);
|
||||
|
||||
expect(processor.closedIssues).toHaveLength(0);
|
||||
expect(processor.staleIssues).toHaveLength(0);
|
||||
// test label should have been removed
|
||||
expect(processor.removedLabelIssues).toHaveLength(1);
|
||||
});
|
||||
|
||||
test('stale label should not be removed if a comment was added by the bot (and the issue should be closed)', async () => {
|
||||
const opts = {...DefaultProcessorOptions, removeStaleWhenUpdated: true};
|
||||
github.context.actor = 'abot';
|
||||
|
||||
Reference in New Issue
Block a user