add tests

This commit is contained in:
Robert Brignull 2020-08-06 17:45:42 +01:00 committed by Robert
parent d5853409b4
commit 657540584e
6 changed files with 81 additions and 8 deletions

14
lib/config-utils.js generated
View file

@ -287,6 +287,15 @@ exports.getConfigFileDirectoryGivenMessage = getConfigFileDirectoryGivenMessage;
function getConfigFilePropertyError(configFile, property, error) {
return 'The configuration file "' + configFile + '" is invalid: property "' + property + '" ' + error;
}
function getNoLanguagesError() {
return "Did not detect any languages to analyze. " +
"Please update input in workflow or check that GitHub detects the correct languages in your repository.";
}
exports.getNoLanguagesError = getNoLanguagesError;
function getUnknownLanguagesError(languages) {
return "Did not recognise the following languages: " + languages.join(', ');
}
exports.getUnknownLanguagesError = getUnknownLanguagesError;
/**
* Gets the set of languages in the current repository
*/
@ -354,8 +363,7 @@ async function getLanguages() {
// If the languages parameter was not given and no languages were
// detected then fail here as this is a workflow configuration error.
if (languages.length === 0) {
throw new Error("Did not detect any languages to analyze. " +
"Please update input in workflow or check that GitHub detects the correct languages in your repository.");
throw new Error(getNoLanguagesError());
}
// Make sure they are supported
const checkedLanguages = [];
@ -376,7 +384,7 @@ async function getLanguages() {
}
}
if (unknownLanguages.length > 0) {
throw new Error("Did not recognise the following languages: " + unknownLanguages.join(', '));
throw new Error(getUnknownLanguagesError(unknownLanguages));
}
return checkedLanguages;
}