Skip to content

Commit 17f172c

Browse files
committed
wip: tighten load-error assertions, measured test budget
Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YD4v2ErCfZk8sfaZe8AYVu
1 parent d634fe5 commit 17f172c

2 files changed

Lines changed: 15 additions & 9 deletions

File tree

‎packages/cli/test/fixtures/plugin-auth-load-failure.hook.mjs‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@
1414
* `@objectstack/runtime` imports `@objectstack/plugin-auth/rate-limit-storage`
1515
* and `/client-address` statically, so denying them would crash the CLI before
1616
* the boot reaches the auth tier, which is a different failure from the one
17-
* under test.
17+
* under test. One side effect is expected and harmless to `serve`:
18+
* `@objectstack/verify` imports the root entry too, so in either mode oclif
19+
* prints a `ModuleLoadError` warning for the `verify` command while it indexes
20+
* the command table.
1821
*
1922
* Both modes make node produce its OWN error, so the refusal is asserted against
2023
* a sentence this file did not write:

‎packages/cli/test/serve-plugin-auth-load-failure-refusal.integration.test.ts‎

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
2-
// test-budget: 30 — spawns the real producer once per single-cause fixture: four boots of the built CLI (a missing and a broken `@objectstack/plugin-auth` in production, the broken one under `--dev`, and production with no stub), each differing only in the input under test; MEASURED_PLACEHOLDER
2+
// test-budget: 20 — spawns the real producer once per single-cause fixture: four boots of the built CLI (a missing and a broken `@objectstack/plugin-auth` in production, the broken one under `--dev`, and production with no stub), each differing only in the input under test; 13.3 s, the slowest of three local runs on a shared container, x 1.25, no CI reading yet
33

44
import { afterAll, beforeAll, describe, expect, it } from 'vitest';
55
import { spawn, type ChildProcessByStdio } from 'node:child_process';
@@ -48,9 +48,14 @@ const HOOK = pathToFileURL(resolve(HERE, 'fixtures/plugin-auth-load-failure.hook
4848
const AUTH_TIER_CONFIG = 'export default {};\n';
4949

5050
const LOAD_FAILURE_TEXT = '@objectstack/plugin-auth failed to load';
51-
/** Node's own sentences for the two stubbed installs — the hook writes neither. */
52-
const MISSING_CAUSE = 'Cannot find module';
53-
const BROKEN_CAUSE = 'does not provide an export named';
51+
/**
52+
* The openings of node's own sentences for the two stubbed installs — the hook
53+
* writes neither. Asserted right after `The load error: `, because the same
54+
* sentence also appears in oclif's warning for the `verify` command (see the
55+
* hook's header), which alone would pass a leg that named no load error.
56+
*/
57+
const MISSING_CAUSE = "Cannot find module '";
58+
const BROKEN_CAUSE = "The requested module 'node:path' does not provide an export named 'createLocalAccountIssuer'";
5459
const SECRET = 'os-adr-0131-d9-load-failure-leg-secret-not-a-real-credential';
5560

5661
type BootChild = ChildProcessByStdio<null, Readable, Readable>;
@@ -129,8 +134,7 @@ async function expectRefused(leg: Leg, cause: string): Promise<string> {
129134
expect(exitCode).not.toBe(0);
130135
expect(output).not.toMatch(READY_BANNER_TAIL);
131136
expect(output).toContain(LOAD_FAILURE_TEXT);
132-
expect(output).toContain(`The load error: `);
133-
expect(output).toContain(cause);
137+
expect(output).toContain(`The load error: ${cause}`);
134138
// Refused instead of the old warn-and-boot line, not after it.
135139
expect(output).not.toContain('⚠ AuthPlugin failed to load');
136140
expect(existsSync(leg.databaseFile), `the refused boot opened its database\n${output}`).toBe(false);
@@ -178,7 +182,6 @@ describe('os serve — a production boot whose plugin-auth fails to load is refu
178182

179183
it('control: --dev with the broken install keeps the warn-and-boot path', async () => {
180184
const output = await expectBoots({ databaseFile: db('broken-dev-no-server'), stub: 'broken', args: ['--dev', '--no-server'] });
181-
expect(output).toContain('⚠ AuthPlugin failed to load');
182-
expect(output).toContain(BROKEN_CAUSE);
185+
expect(output).toContain(`⚠ AuthPlugin failed to load: ${BROKEN_CAUSE}`);
183186
}, 240_000);
184187
});

0 commit comments

Comments
 (0)