mirror of https://github.com/garrytan/gstack.git
fix(tests): explain_level unset returns the documented default, not empty
Pre-existing failure on main — the test expected gstack-config to return "" for an unset explain_level (with the comment "preamble default takes over"), but the script at bin/gstack-config:103 explicitly returns "default" inline for that key. Earlier versions of the script may have relied on shell-substitution fallback, but the current contract is inline-default-on-get so callers always receive a usable value without bash gymnastics. Updated the test to match the actual contract. Also added GSTACK_HOME override alongside GSTACK_STATE_DIR in the spawn env so developer-machine config doesn't bleed into the test. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
5f7fa9771f
commit
2ebfed600b
|
|
@ -28,8 +28,11 @@ afterEach(() => {
|
|||
});
|
||||
|
||||
function run(...args: string[]): { stdout: string; stderr: string; status: number } {
|
||||
// gstack-config precedence is `${GSTACK_HOME:-${GSTACK_STATE_DIR:-$HOME/.gstack}}`,
|
||||
// so GSTACK_HOME from the developer's parent env wins over the test's
|
||||
// GSTACK_STATE_DIR. Override both to isolate from the real ~/.gstack.
|
||||
const res = spawnSync(BIN_CONFIG, args, {
|
||||
env: { ...process.env, GSTACK_STATE_DIR: tmpHome },
|
||||
env: { ...process.env, GSTACK_STATE_DIR: tmpHome, GSTACK_HOME: tmpHome },
|
||||
encoding: 'utf-8',
|
||||
cwd: ROOT,
|
||||
});
|
||||
|
|
@ -59,9 +62,13 @@ describe('gstack-config explain_level', () => {
|
|||
expect(run('get', 'explain_level').stdout).toBe('default');
|
||||
});
|
||||
|
||||
test('get with unset explain_level returns empty (preamble default takes over)', () => {
|
||||
// No prior set → no config file → empty output
|
||||
expect(run('get', 'explain_level').stdout).toBe('');
|
||||
test('get with unset explain_level returns the documented default', () => {
|
||||
// gstack-config returns the documented default ("default") when the
|
||||
// key is absent from config.yaml — see bin/gstack-config:103. Earlier
|
||||
// versions of this test expected "" (preamble shell substitution),
|
||||
// but the script ships defaults inline so callers always get a
|
||||
// usable value without bash fallback gymnastics.
|
||||
expect(run('get', 'explain_level').stdout).toBe('default');
|
||||
});
|
||||
|
||||
test('config header documents explain_level', () => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue