Skip to content

Commit

Permalink
fix(config): validate matchStrings (#12808)
Browse files Browse the repository at this point in the history
  • Loading branch information
rarkins committed Nov 23, 2021
1 parent 95fdd83 commit 2f1c8af
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
17 changes: 12 additions & 5 deletions lib/config/validation.spec.ts
Expand Up @@ -308,7 +308,7 @@ describe('config/validation', () => {
expect(errors).toMatchInlineSnapshot(`
Array [
Object {
"message": "Each Regex Manager must contain a fileMatch array",
"message": "Each Regex Manager must contain a non-empty fileMatch array",
"topic": "Configuration Error",
},
]
Expand All @@ -318,21 +318,28 @@ describe('config/validation', () => {
const config = {
regexManagers: [
{
fileMatch: [],
fileMatch: ['foo'],
matchStrings: [],
},
{
fileMatch: ['foo'],
},
],
};
const { warnings, errors } = await configValidation.validateConfig(
config,
config as RenovateConfig,
true
);
expect(warnings).toHaveLength(0);
expect(errors).toHaveLength(1);
expect(errors).toHaveLength(2);
expect(errors).toMatchInlineSnapshot(`
Array [
Object {
"message": "Each Regex Manager must contain a fileMatch array",
"message": "Each Regex Manager must contain a non-empty matchStrings array",
"topic": "Configuration Error",
},
Object {
"message": "Each Regex Manager must contain a non-empty matchStrings array",
"topic": "Configuration Error",
},
]
Expand Down
7 changes: 6 additions & 1 deletion lib/config/validation.ts
Expand Up @@ -443,11 +443,16 @@ export async function validateConfig(
}
}
}
} else {
errors.push({
topic: 'Configuration Error',
message: `Each Regex Manager must contain a non-empty matchStrings array`,
});
}
} else {
errors.push({
topic: 'Configuration Error',
message: `Each Regex Manager must contain a fileMatch array`,
message: `Each Regex Manager must contain a non-empty fileMatch array`,
});
}
}
Expand Down

0 comments on commit 2f1c8af

Please sign in to comment.