fix: error messages on tests

Signed-off-by: Juan Pablo Garcia Ripa <sarabadu@gmail.com>
This commit is contained in:
Juan Pablo Garcia Ripa
2025-09-25 20:34:04 +02:00
parent f4470cd3a3
commit 9a16824fdb
2 changed files with 5 additions and 7 deletions
@@ -27,7 +27,8 @@ import {
import { BackendInitializer } from './BackendInitializer';
import { mockServices } from '@backstage/backend-test-utils';
import { BackendStartupError } from './BackendStartupError';
import { CONFIG_KEY_PART_PATTERN } from '@backstage/config';
const ID_PATTERN = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/i;
const baseFactories = [
mockServices.rootLifecycle.factory(),
@@ -1026,7 +1027,7 @@ describe('BackendInitializer', () => {
}),
);
await expect(init.start()).rejects.toThrow(
`Invalid pluginId 'test:invalid&id', must match the pattern ${CONFIG_KEY_PART_PATTERN} (letters, digits, dashes, and underscores only, starting with a letter)`,
`Invalid pluginId 'test:invalid&id', must match the pattern ${ID_PATTERN} (letters, digits, and dashes only, starting with a letter)`,
);
});
@@ -1056,7 +1057,7 @@ describe('BackendInitializer', () => {
}),
);
await expect(init.start()).rejects.toThrow(
`Invalid moduleId 'invalid:module&id' for plugin 'test', must match the pattern ${CONFIG_KEY_PART_PATTERN} (letters, digits, dashes, and underscores only, starting with a letter)`,
`Invalid moduleId 'invalid:module&id' for plugin 'test', must match the pattern ${ID_PATTERN} (letters, digits, and dashes only, starting with a letter)`,
);
});
@@ -14,7 +14,7 @@
* limitations under the License.
*/
import { AppConfig } from '@backstage/config';
import { AppConfig, CONFIG_KEY_PART_PATTERN } from '@backstage/config';
import { assertError } from '@backstage/errors';
import { JsonObject } from '@backstage/types';
import { AsyncConfigSourceGenerator, ConfigSource } from './types';
@@ -84,9 +84,6 @@ export class EnvConfigSource implements ConfigSource {
const ENV_PREFIX = 'APP_CONFIG_';
// Update the same pattern in config package if this is changed
const CONFIG_KEY_PART_PATTERN = /^[a-z][a-z0-9]*(?:[-_:][a-z0-9]+)*$/i;
/**
* Read runtime configuration from the environment.
*