Skip to content

Commit 6222edf

Browse files
committed
Move error messages from config-utils to their own file
1 parent 3305d21 commit 6222edf

File tree

4 files changed

+143
-134
lines changed

4 files changed

+143
-134
lines changed

lib/init-action.js

Lines changed: 46 additions & 40 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/config-utils.test.ts

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import * as api from "./api-client";
1212
import { CachingKind } from "./caching-utils";
1313
import { createStubCodeQL } from "./codeql";
1414
import * as configUtils from "./config-utils";
15+
import * as errorMessages from "./error-messages";
1516
import { Feature } from "./feature-flags";
1617
import * as gitUtils from "./git-utils";
1718
import { KnownLanguage, Language } from "./languages";
@@ -341,7 +342,7 @@ test("load input outside of workspace", async (t) => {
341342
t.deepEqual(
342343
err,
343344
new ConfigurationError(
344-
configUtils.getConfigFileOutsideWorkspaceErrorMessage(
345+
errorMessages.getConfigFileOutsideWorkspaceErrorMessage(
345346
path.join(tempDir, "../input"),
346347
),
347348
),
@@ -368,7 +369,7 @@ test("load non-local input with invalid repo syntax", async (t) => {
368369
t.deepEqual(
369370
err,
370371
new ConfigurationError(
371-
configUtils.getConfigFileRepoFormatInvalidMessage(
372+
errorMessages.getConfigFileRepoFormatInvalidMessage(
372373
"octo-org/codeql-config@main",
373374
),
374375
),
@@ -397,7 +398,7 @@ test("load non-existent input", async (t) => {
397398
t.deepEqual(
398399
err,
399400
new ConfigurationError(
400-
configUtils.getConfigFileDoesNotExistErrorMessage(
401+
errorMessages.getConfigFileDoesNotExistErrorMessage(
401402
path.join(tempDir, "input"),
402403
),
403404
),
@@ -604,7 +605,7 @@ test("Remote config handles the case where a directory is provided", async (t) =
604605
t.deepEqual(
605606
err,
606607
new ConfigurationError(
607-
configUtils.getConfigFileDirectoryGivenMessage(repoReference),
608+
errorMessages.getConfigFileDirectoryGivenMessage(repoReference),
608609
),
609610
);
610611
}
@@ -632,7 +633,7 @@ test("Invalid format of remote config handled correctly", async (t) => {
632633
t.deepEqual(
633634
err,
634635
new ConfigurationError(
635-
configUtils.getConfigFileFormatInvalidMessage(repoReference),
636+
errorMessages.getConfigFileFormatInvalidMessage(repoReference),
636637
),
637638
);
638639
}
@@ -660,7 +661,7 @@ test("No detected languages", async (t) => {
660661
} catch (err) {
661662
t.deepEqual(
662663
err,
663-
new ConfigurationError(configUtils.getNoLanguagesError()),
664+
new ConfigurationError(errorMessages.getNoLanguagesError()),
664665
);
665666
}
666667
});
@@ -683,7 +684,7 @@ test("Unknown languages", async (t) => {
683684
t.deepEqual(
684685
err,
685686
new ConfigurationError(
686-
configUtils.getUnknownLanguagesError(["rubbish", "english"]),
687+
errorMessages.getUnknownLanguagesError(["rubbish", "english"]),
687688
),
688689
);
689690
}
@@ -1097,28 +1098,28 @@ const mockRepositoryNwo = parseRepositoryNwo("owner/repo");
10971098
languagesInput: "",
10981099
languagesInRepository: ["html"],
10991100
expectedApiCall: true,
1100-
expectedError: configUtils.getNoLanguagesError(),
1101+
expectedError: errorMessages.getNoLanguagesError(),
11011102
},
11021103
{
11031104
name: "no languages",
11041105
languagesInput: "",
11051106
languagesInRepository: [],
11061107
expectedApiCall: true,
1107-
expectedError: configUtils.getNoLanguagesError(),
1108+
expectedError: errorMessages.getNoLanguagesError(),
11081109
},
11091110
{
11101111
name: "unrecognized languages from input",
11111112
languagesInput: "a, b, c, javascript",
11121113
languagesInRepository: [],
11131114
expectedApiCall: false,
1114-
expectedError: configUtils.getUnknownLanguagesError(["a", "b"]),
1115+
expectedError: errorMessages.getUnknownLanguagesError(["a", "b"]),
11151116
},
11161117
{
11171118
name: "extractors that aren't languages aren't included (specified)",
11181119
languagesInput: "html",
11191120
languagesInRepository: [],
11201121
expectedApiCall: false,
1121-
expectedError: configUtils.getUnknownLanguagesError(["html"]),
1122+
expectedError: errorMessages.getUnknownLanguagesError(["html"]),
11221123
},
11231124
{
11241125
name: "extractors that aren't languages aren't included (autodetected)",

0 commit comments

Comments
 (0)