test(fleet): make CRUD projection recovery deterministic
All checks were successful
ci/woodpecker/pr/ci Pipeline was successful

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Jarvis
2026-07-15 06:54:02 -05:00
parent 23d58cdb90
commit 128cc81c39

View File

@@ -4,7 +4,6 @@ import { join } from 'node:path';
import { Command } from 'commander'; import { Command } from 'commander';
import { afterEach, describe, expect, it, vi } from 'vitest'; import { afterEach, describe, expect, it, vi } from 'vitest';
import { fleetAgentMutationExitCode } from './fleet-agent-crud-command.js'; import { fleetAgentMutationExitCode } from './fleet-agent-crud-command.js';
import { applyPreparedAgentEnvironmentProjection } from '../fleet/generated-env-boundary.js';
import { registerFleetCommand, type FleetCommandDeps } from './fleet.js'; import { registerFleetCommand, type FleetCommandDeps } from './fleet.js';
const roster = ` const roster = `
@@ -389,11 +388,9 @@ describe('mosaic fleet local roster mutations', (): void => {
const agentsDir = join(home, 'fleet', 'agents'); const agentsDir = join(home, 'fleet', 'agents');
const captured = output(); const captured = output();
try {
await program(home, { await program(home, {
projectionApplier: async (prepared): Promise<unknown> => { projectionApplier: async (): Promise<never> => {
await chmod(agentsDir, 0o500); throw new Error('injected projection failure');
return applyPreparedAgentEnvironmentProjection(prepared);
}, },
}).parseAsync([ }).parseAsync([
'node', 'node',
@@ -405,9 +402,6 @@ describe('mosaic fleet local roster mutations', (): void => {
'--agent', '--agent',
JSON.stringify(agent), JSON.stringify(agent),
]); ]);
} finally {
await chmod(agentsDir, 0o700);
}
expect(JSON.parse(captured.lines.join('\n'))).toMatchObject({ expect(JSON.parse(captured.lines.join('\n'))).toMatchObject({
applied: false, applied: false,
@@ -525,17 +519,12 @@ describe('mosaic fleet local roster mutations', (): void => {
JSON.stringify(agent), JSON.stringify(agent),
]); ]);
try {
captured.lines.length = 0; captured.lines.length = 0;
await program(home, { await program(home, {
projectionApplier: async (prepared): Promise<unknown> => { projectionApplier: async (): Promise<never> => {
await chmod(agentsDir, 0o500); throw new Error('injected projection failure');
return applyPreparedAgentEnvironmentProjection(prepared);
}, },
}).parseAsync(['node', 'mosaic', 'fleet', 'delete', 'coder0', '--expected-generation', '8']); }).parseAsync(['node', 'mosaic', 'fleet', 'delete', 'coder0', '--expected-generation', '8']);
} finally {
await chmod(agentsDir, 0o700);
}
expect(JSON.parse(captured.lines.pop() ?? '')).toMatchObject({ expect(JSON.parse(captured.lines.pop() ?? '')).toMatchObject({
applied: false, applied: false,