refactor(test): separate directory initialization from configuration in TestRig

- Refactor TestRig.setup to handle only directory creation by default.
- Add TestRig.configure to apply settings and fake responses.
- Update hook integration tests to use the new setup/configure pattern,
  avoiding brittle double setup calls.
This commit is contained in:
Abhi
2026-02-06 12:39:16 -05:00
parent ed85166a41
commit fb3dfea925
3 changed files with 193 additions and 198 deletions

View File

@@ -361,6 +361,20 @@ export class TestRig {
this.homeDir = join(testFileDir, sanitizedName + '-home');
mkdirSync(this.testDir, { recursive: true });
mkdirSync(this.homeDir, { recursive: true });
if (options.settings || options.fakeResponsesPath) {
this.configure(options);
}
}
configure(options: {
settings?: Record<string, unknown>;
fakeResponsesPath?: string;
}) {
if (!this.testDir || !this.homeDir) {
throw new Error('TestRig must be setup before calling configure');
}
if (options.fakeResponsesPath) {
this.fakeResponsesPath = join(this.testDir, 'fake-responses.json');
this.originalFakeResponsesPath = options.fakeResponsesPath;