test(fleet): make CRUD projection recovery deterministic
All checks were successful
ci/woodpecker/pr/ci Pipeline was successful
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:
@@ -4,7 +4,6 @@ import { join } from 'node:path';
|
||||
import { Command } from 'commander';
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest';
|
||||
import { fleetAgentMutationExitCode } from './fleet-agent-crud-command.js';
|
||||
import { applyPreparedAgentEnvironmentProjection } from '../fleet/generated-env-boundary.js';
|
||||
import { registerFleetCommand, type FleetCommandDeps } from './fleet.js';
|
||||
|
||||
const roster = `
|
||||
@@ -389,25 +388,20 @@ describe('mosaic fleet local roster mutations', (): void => {
|
||||
const agentsDir = join(home, 'fleet', 'agents');
|
||||
const captured = output();
|
||||
|
||||
try {
|
||||
await program(home, {
|
||||
projectionApplier: async (prepared): Promise<unknown> => {
|
||||
await chmod(agentsDir, 0o500);
|
||||
return applyPreparedAgentEnvironmentProjection(prepared);
|
||||
},
|
||||
}).parseAsync([
|
||||
'node',
|
||||
'mosaic',
|
||||
'fleet',
|
||||
'create',
|
||||
'--expected-generation',
|
||||
'7',
|
||||
'--agent',
|
||||
JSON.stringify(agent),
|
||||
]);
|
||||
} finally {
|
||||
await chmod(agentsDir, 0o700);
|
||||
}
|
||||
await program(home, {
|
||||
projectionApplier: async (): Promise<never> => {
|
||||
throw new Error('injected projection failure');
|
||||
},
|
||||
}).parseAsync([
|
||||
'node',
|
||||
'mosaic',
|
||||
'fleet',
|
||||
'create',
|
||||
'--expected-generation',
|
||||
'7',
|
||||
'--agent',
|
||||
JSON.stringify(agent),
|
||||
]);
|
||||
|
||||
expect(JSON.parse(captured.lines.join('\n'))).toMatchObject({
|
||||
applied: false,
|
||||
@@ -525,17 +519,12 @@ describe('mosaic fleet local roster mutations', (): void => {
|
||||
JSON.stringify(agent),
|
||||
]);
|
||||
|
||||
try {
|
||||
captured.lines.length = 0;
|
||||
await program(home, {
|
||||
projectionApplier: async (prepared): Promise<unknown> => {
|
||||
await chmod(agentsDir, 0o500);
|
||||
return applyPreparedAgentEnvironmentProjection(prepared);
|
||||
},
|
||||
}).parseAsync(['node', 'mosaic', 'fleet', 'delete', 'coder0', '--expected-generation', '8']);
|
||||
} finally {
|
||||
await chmod(agentsDir, 0o700);
|
||||
}
|
||||
captured.lines.length = 0;
|
||||
await program(home, {
|
||||
projectionApplier: async (): Promise<never> => {
|
||||
throw new Error('injected projection failure');
|
||||
},
|
||||
}).parseAsync(['node', 'mosaic', 'fleet', 'delete', 'coder0', '--expected-generation', '8']);
|
||||
|
||||
expect(JSON.parse(captured.lines.pop() ?? '')).toMatchObject({
|
||||
applied: false,
|
||||
|
||||
Reference in New Issue
Block a user