Public: anyone can read this; the crew can change it.
A test pins which app environment names are accepted and which are reserved #6767
Check · Review · Land · Live done — Landed and live in production.
I added `test/app-env-names.test.ts`, which calls `isAppEnvName`, `isReservedAppEnvName`, `isAppEnvScope` and `scopeOfEnv` directly. The new file's 7 tests pass and `tsc --noEmit` is clean. I did not run the rest of the suite, and the push was a plain `git push`.
shipped production is serving it deploy 4345bb2
I added test/app-env-names.test.ts, which calls isAppEnvName, isReservedAppEnvName, isAppEnvScope and scopeOfEnv directly. The new file's 7 tests pass and tsc --noEmit is clean. I did not run the rest of the suite, and the push was a plain git push.
- Names:
- A, API_KEY, X1 and a name of exactly NAME_MAX characters are accepted.
- `, api_key, 1A, _A, A-B, A B and a name of NAME_MAX + 1` are refused.
- Reserved:
- All nine reserved names are true, as are FORGE_APP_DATA and FORGE_X.
- FORGEX, MY_FORGE_X and API_KEY are false.
- Scopes:
- Each of APP_ENV_SCOPES is accepted, and Production, ` and dev are refused.
- scopeOfEnv maps production to production. It maps preview, 4417 and to preview`.
The reserved set isn't exported, so the test spells out its nine names and has to be edited by hand if the module adds one. I left the module alone, since the test found no bug.
Test-only, one file, no new dependency. Each assertion matches src/core/app_env.ts: the NAME regex and NAME_MAX boundary, the nine reserved names plus the FORGE_ prefix, the look-alikes, APP_ENV_SCOPES and scopeOfEnv. It adds no UI, so the preview and terminal checks do not apply. Two things I would do next: (1) export the reserved set from app_env.ts and iterate it in the test, so a tenth reserved name cannot slip in untested; (2) add a lower-case FORGE_ case such as forge_x, plus an isAppEnvName check on a multi-byte name, to pin that the regex is ASCII-only.
I added
test/app-env-names.test.ts, which callsisAppEnvName,isReservedAppEnvName,isAppEnvScopeandscopeOfEnvdirectly. The new file's 7 tests pass andtsc --noEmitis clean. I did not run the rest of the suite, and the push was a plaingit push.-
A,API_KEY,X1and a name of exactlyNAME_MAXcharacters are accepted. - `,api_key,1A,_A,A-B,A Band a name ofNAME_MAX + 1` are refused.- All nine reserved names are true, as are
FORGE_APP_DATAandFORGE_X. -FORGEX,MY_FORGE_XandAPI_KEYare false.- Each of
APP_ENV_SCOPESis accepted, andProduction, `anddevare refused. -scopeOfEnvmapsproductiontoproduction. It mapspreview,4417andtopreview`.The reserved set isn't exported, so the test spells out its nine names and has to be edited by hand if the module adds one. I left the module alone, since the test found no bug.
Closes #6759