Turn enablement errors into configuration errors

This commit is contained in:
Michael B. Gale
2025-10-28 21:17:30 +00:00
parent ac9aeee226
commit 53acf0b8aa
8 changed files with 120 additions and 0 deletions

View File

@@ -169,4 +169,39 @@ test("wrapApiConfigurationError correctly wraps specific configuration errors",
res,
new util.ConfigurationError("Resource not accessible by integration"),
);
// Enablement errors.
const codeSecurityNotEnabledError = new util.HTTPError(
"Code Security must be enabled for this repository to use code scanning",
403,
);
res = api.wrapApiConfigurationError(codeSecurityNotEnabledError);
t.deepEqual(
res,
new util.ConfigurationError(
`Please verify that the necessary features are enabled: ${codeSecurityNotEnabledError.message}`,
),
);
const advancedSecurityNotEnabledError = new util.HTTPError(
"Advanced Security must be enabled for this repository to use code scanning",
403,
);
res = api.wrapApiConfigurationError(advancedSecurityNotEnabledError);
t.deepEqual(
res,
new util.ConfigurationError(
`Please verify that the necessary features are enabled: ${advancedSecurityNotEnabledError.message}`,
),
);
const codeScanningNotEnabledError = new util.HTTPError(
"Code Scanning is not enabled for this repository. Please enable code scanning in the repository settings.",
403,
);
res = api.wrapApiConfigurationError(codeScanningNotEnabledError);
t.deepEqual(
res,
new util.ConfigurationError(
`Please verify that the necessary features are enabled: ${codeScanningNotEnabledError.message}`,
),
);
});