Skip to content

Commit 194ba0e

Browse files
committed
Make error message tests less brittle
1 parent 53acf0b commit 194ba0e

File tree

8 files changed

+34
-10
lines changed

8 files changed

+34
-10
lines changed

‎lib/analyze-action.js‎

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎lib/init-action-post.js‎

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎lib/init-action.js‎

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎lib/setup-codeql-action.js‎

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎lib/upload-lib.js‎

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎lib/upload-sarif-action.js‎

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/api-client.test.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ test("wrapApiConfigurationError correctly wraps specific configuration errors",
179179
t.deepEqual(
180180
res,
181181
new util.ConfigurationError(
182-
`Please verify that the necessary features are enabled: ${codeSecurityNotEnabledError.message}`,
182+
api.getFeatureEnablementError(codeSecurityNotEnabledError.message),
183183
),
184184
);
185185
const advancedSecurityNotEnabledError = new util.HTTPError(
@@ -190,7 +190,7 @@ test("wrapApiConfigurationError correctly wraps specific configuration errors",
190190
t.deepEqual(
191191
res,
192192
new util.ConfigurationError(
193-
`Please verify that the necessary features are enabled: ${advancedSecurityNotEnabledError.message}`,
193+
api.getFeatureEnablementError(advancedSecurityNotEnabledError.message),
194194
),
195195
);
196196
const codeScanningNotEnabledError = new util.HTTPError(
@@ -201,7 +201,7 @@ test("wrapApiConfigurationError correctly wraps specific configuration errors",
201201
t.deepEqual(
202202
res,
203203
new util.ConfigurationError(
204-
`Please verify that the necessary features are enabled: ${codeScanningNotEnabledError.message}`,
204+
api.getFeatureEnablementError(codeScanningNotEnabledError.message),
205205
),
206206
);
207207
});

‎src/api-client.ts‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,12 @@ function isEnablementError(msg: string) {
291291
].some((pattern) => pattern.test(msg));
292292
}
293293

294+
// TODO: Move to `error-messages.ts` after refactoring import order to avoid cycle
295+
// since `error-messages.ts` currently depends on this file.
296+
export function getFeatureEnablementError(message: string): string {
297+
return `Please verify that the necessary features are enabled: ${message}`;
298+
}
299+
294300
export function wrapApiConfigurationError(e: unknown) {
295301
const httpError = asHTTPError(e);
296302
if (httpError !== undefined) {
@@ -314,7 +320,7 @@ export function wrapApiConfigurationError(e: unknown) {
314320
}
315321
if (isEnablementError(httpError.message)) {
316322
return new ConfigurationError(
317-
`Please verify that the necessary features are enabled: ${httpError.message}`,
323+
getFeatureEnablementError(httpError.message),
318324
);
319325
}
320326
if (httpError.status === 429) {

0 commit comments

Comments
 (0)