fix(schedule): don’t massage null value

This commit is contained in:
Rhys Arkins 2018-10-05 09:59:32 +02:00
parent 3b387e92db
commit 77997770f1
4 changed files with 8 additions and 5 deletions

View file

@ -214,10 +214,7 @@ function migrateConfig(config) {
isMigrated = true; isMigrated = true;
migratedConfig.baseBranches = is.array(val) ? val : [val]; migratedConfig.baseBranches = is.array(val) ? val : [val];
delete migratedConfig.baseBranch; delete migratedConfig.baseBranch;
} else if (key === 'schedule' && !val) { } else if (key === 'schedule' && val) {
isMigrated = true;
migratedConfig.schedule = [];
} else if (key === 'schedule') {
// massage to array first // massage to array first
const schedules = is.string(val) ? [val] : val; const schedules = is.string(val) ? [val] : val;
// split 'and' // split 'and'

View file

@ -21,6 +21,9 @@ function hasValidTimezone(timezone) {
function hasValidSchedule(schedule) { function hasValidSchedule(schedule) {
let message; let message;
if (!schedule) {
return [true];
}
// check if any of the schedules fail to parse // check if any of the schedules fail to parse
const hasFailedSchedules = schedule.some(scheduleText => { const hasFailedSchedules = schedule.some(scheduleText => {
const massagedText = fixShortHours(scheduleText); const massagedText = fixShortHours(scheduleText);

View file

@ -98,7 +98,7 @@ Object {
"minor": Object { "minor": Object {
"automerge": true, "automerge": true,
}, },
"schedule": Array [], "schedule": null,
}, },
Object { Object {
"depTypeList": Array [ "depTypeList": Array [

View file

@ -14,6 +14,9 @@ describe('workers/branch/schedule', () => {
beforeEach(() => { beforeEach(() => {
jest.resetAllMocks(); jest.resetAllMocks();
}); });
it('returns true for null', () => {
expect(schedule.hasValidSchedule(null)[0]).toBe(true);
});
it('returns false for invalid schedule', () => { it('returns false for invalid schedule', () => {
expect(schedule.hasValidSchedule(['foo'])[0]).toBe(false); expect(schedule.hasValidSchedule(['foo'])[0]).toBe(false);
}); });