Skip to content

Commit 9c57ae1

Browse files
jamietannaClaude Sonnet 4.6
andauthored
test(config): ensure no duplicate environment variable names (renovatebot#42204)
As we continue to be more careful with our environment variable usage, we should make sure it's not possible to ever have a clash. Co-authored-by: Claude Sonnet 4.6 <jamie.tanna+claude-code@mend.io>
1 parent cb86e66 commit 9c57ae1

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

lib/workers/global/config/parse/env.spec.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { MockInstance } from 'vitest';
2+
import { getOptions } from '../../../../config/options/index.ts';
23
import type { RequiredConfig } from '../../../../config/types.ts';
34
import { logger } from '../../../../logger/index.ts';
45
import * as env from './env.ts';
@@ -391,6 +392,27 @@ describe('workers/global/config/parse/env', () => {
391392
});
392393
});
393394

395+
it('has no duplicate env names across options', () => {
396+
const options = getOptions();
397+
const envNameToOptions = new Map<string, string[]>();
398+
399+
for (const option of options) {
400+
const envName = env.getEnvName(option);
401+
if (envName === '') {
402+
continue;
403+
}
404+
const existing = envNameToOptions.get(envName) ?? [];
405+
existing.push(option.name);
406+
envNameToOptions.set(envName, existing);
407+
}
408+
409+
const duplicates = [...envNameToOptions.entries()]
410+
.filter(([, names]) => names.length > 1)
411+
.map(([envName, names]) => `${envName}: ${names.join(', ')}`);
412+
413+
expect(duplicates).toEqual([]);
414+
});
415+
394416
describe('.getEnvName(definition)', () => {
395417
it('returns empty', () => {
396418
const option: ParseConfigOptions = {

0 commit comments

Comments
 (0)