mirror of
https://github.com/actions/stale.git
synced 2025-12-10 20:21:20 +00:00
fix(remove-label): do not encode the label to make sure to remove it (#220)
* test: add two more tests relating the label syntax issues both are failing * chore: add more logs and fix the tests on error meaning that I did not find a reproduction... * chore: minor improvements with the types and logs * fix(remove-label): do not encode the label to make sure to remove it could lead to an issue since based on the comment it was here on purpose
This commit is contained in:
committed by
GitHub
parent
107018c400
commit
ddc7648635
@@ -1,11 +1,8 @@
|
||||
import * as core from '@actions/core';
|
||||
import * as github from '@actions/github';
|
||||
import {Octokit} from '@octokit/rest';
|
||||
|
||||
import {
|
||||
IssueProcessor,
|
||||
Issue,
|
||||
Label,
|
||||
IssueProcessorOptions
|
||||
} from '../src/IssueProcessor';
|
||||
|
||||
@@ -189,6 +186,66 @@ test('processing a stale issue will close it', async () => {
|
||||
expect(processor.closedIssues.length).toEqual(1);
|
||||
});
|
||||
|
||||
test('processing a stale issue containing a space in the label will close it', async () => {
|
||||
const TestIssueList: Issue[] = [
|
||||
generateIssue(
|
||||
1,
|
||||
'A stale issue that should be closed',
|
||||
'2020-01-01T17:00:00Z',
|
||||
false,
|
||||
['state: stale']
|
||||
)
|
||||
];
|
||||
|
||||
const opts: IssueProcessorOptions = {
|
||||
...DefaultProcessorOptions,
|
||||
staleIssueLabel: 'state: stale'
|
||||
};
|
||||
|
||||
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 issue containing a slash in the label will close it', async () => {
|
||||
const TestIssueList: Issue[] = [
|
||||
generateIssue(
|
||||
1,
|
||||
'A stale issue that should be closed',
|
||||
'2020-01-01T17:00:00Z',
|
||||
false,
|
||||
['lifecycle/stale']
|
||||
)
|
||||
];
|
||||
|
||||
const opts: IssueProcessorOptions = {
|
||||
...DefaultProcessorOptions,
|
||||
staleIssueLabel: 'lifecycle/stale'
|
||||
};
|
||||
|
||||
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', async () => {
|
||||
const TestIssueList: Issue[] = [
|
||||
generateIssue(
|
||||
@@ -650,6 +707,38 @@ test('stale label should not be removed if a comment was added by the bot (and t
|
||||
expect(processor.removedLabelIssues.length).toEqual(0);
|
||||
});
|
||||
|
||||
test('stale label containing a space should be removed if a comment was added to a stale issue', async () => {
|
||||
const TestIssueList: Issue[] = [
|
||||
generateIssue(
|
||||
1,
|
||||
'An issue that should un-stale',
|
||||
'2020-01-01T17:00:00Z',
|
||||
false,
|
||||
['stat: stale']
|
||||
)
|
||||
];
|
||||
|
||||
const opts: IssueProcessorOptions = {
|
||||
...DefaultProcessorOptions,
|
||||
removeStaleWhenUpdated: true,
|
||||
staleIssueLabel: 'stat: stale'
|
||||
};
|
||||
|
||||
const processor = new IssueProcessor(
|
||||
opts,
|
||||
async p => (p == 1 ? TestIssueList : []),
|
||||
async (num, dt) => [{user: {login: 'notme', type: 'User'}}], // return a fake comment to indicate there was an update
|
||||
async (issue, label) => new Date().toDateString()
|
||||
);
|
||||
|
||||
// process our fake issue list
|
||||
await processor.processIssues(1);
|
||||
|
||||
expect(processor.closedIssues.length).toEqual(0);
|
||||
expect(processor.staleIssues.length).toEqual(0);
|
||||
expect(processor.removedLabelIssues.length).toEqual(1);
|
||||
});
|
||||
|
||||
test('stale issues should not be closed until after the closed number of days', async () => {
|
||||
let lastUpdate = new Date();
|
||||
lastUpdate.setDate(lastUpdate.getDate() - 5);
|
||||
|
||||
Reference in New Issue
Block a user