24 lines
1.4 KiB
TypeScript
24 lines
1.4 KiB
TypeScript
// Loaded before every test file (bunfig.toml): no real waiting between the re-checks of cli/lib/upsert.ts or for
|
|
// the store's list to settle after a create (cli/apple/iap.ts).
|
|
import { afterEach } from 'bun:test';
|
|
import { mkdtempSync } from 'node:fs';
|
|
import { tmpdir } from 'node:os';
|
|
import { join } from 'node:path';
|
|
|
|
process.env.STOREBOUND_UPSERT_WAIT_MS = '0';
|
|
process.env.STOREBOUND_LIST_SETTLE_MS ??= '0';
|
|
|
|
// The machine-wide stores (credential profiles, the app folder list) of the person running the tests are never read
|
|
// or written: every test process gets empty ones (a test that needs content points these at its own folder).
|
|
const machine = mkdtempSync(join(tmpdir(), 'storebound-machine-'));
|
|
process.env.STOREBOUND_CREDENTIALS_DIR = join(machine, 'credentials');
|
|
process.env.STOREBOUND_REGISTRY = join(machine, 'projects.json');
|
|
process.env.STOREBOUND_LOCK_DIR = join(machine, 'locks');
|
|
// the credential broker of this machine (~/.storebound/broker.json, cli/lib/broker.ts) is never asked either
|
|
process.env.STOREBOUND_BROKER_CONFIG = join(machine, 'broker.json');
|
|
delete process.env.STOREBOUND_BROKER_URL;
|
|
delete process.env.STOREBOUND_BROKER_KEY_FILE;
|
|
|
|
// Commands run in-process set process.exitCode on purpose (a check with problems, a declined confirmation:
|
|
// DECLINED_EXIT in cli/lib/ctx.ts). Tests assert it where it matters; it must not leak into bun test's own exit code.
|
|
afterEach(() => { process.exitCode = 0; });
|