Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 33 additions & 6 deletions packages/cli/src/__tests__/runtime-host-cli-context.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@ import {
RUNTIME_HOST_PROTOCOL_VERSION,
RUNTIME_HOST_REGISTRATION_SCHEMA_VERSION,
type HostIncompatible,
type HostRegistration,
} from '@maka/runtime-host/protocol';
import {
connectRuntimeHostCli,
resolveRuntimeHostCliConflictDecision,
RuntimeHostCliConflictError,
shouldRetryRuntimeHostConflict,
} from '../runtime-host-cli-context.js';
Expand Down Expand Up @@ -96,6 +98,31 @@ test('CLI Runtime Host bootstrap launches the execution composition', async () =
assert.equal(closes, 1);
});

test('CLI refuses a staged Host whose durable installation claim is missing', async () => {
let closes = 0;
await assert.rejects(
connectRuntimeHostCli(
{ rootPath: '/runtime-host-root' },
{
connectOrSpawn: async () => ({
kind: 'connected',
registration: hostRegistration({
generation: `npm-global-handoff:${'a'.repeat(64)}`,
}),
connection: {
close: async () => {
closes += 1;
},
} as RuntimeHostConnection,
}),
readDeploymentRecord: async () => undefined,
},
),
/RUNTIME_HOST_RECOVERY_REQUIRED/u,
);
assert.equal(closes, 1);
});

test('non-interactive CLI reports how to retire an incompatible Runtime Host', async () => {
assert.ok(RUNTIME_HOST_COMPATIBILITY_EPOCH > V0_1_11_HOST_COMPATIBILITY_EPOCH);
await assert.rejects(
Expand Down Expand Up @@ -181,6 +208,11 @@ test('Runtime Host conflict waits only after an explicit wait answer', () => {
assert.equal(shouldRetryRuntimeHostConflict('c'), false);
assert.equal(shouldRetryRuntimeHostConflict('cancel'), false);
assert.equal(shouldRetryRuntimeHostConflict('unexpected'), false);
assert.equal(resolveRuntimeHostCliConflictDecision('r', true), 'restart');
assert.equal(resolveRuntimeHostCliConflictDecision(' restart ', true), 'restart');
assert.equal(resolveRuntimeHostCliConflictDecision('r', false), 'cancel');
assert.equal(resolveRuntimeHostCliConflictDecision('w', true), 'wait');
assert.equal(resolveRuntimeHostCliConflictDecision('', true), 'cancel');
});

test('CLI reports an actionable stored-data startup failure', async () => {
Expand Down Expand Up @@ -476,12 +508,7 @@ test('remote profiles preserve shared compatibility errors', async () => {
}
});

function hostRegistration(
overrides: Partial<{
compatibilityEpoch: number;
lifecycleMode: 'ephemeral' | 'service';
}> = {},
) {
function hostRegistration(overrides: Partial<HostRegistration> = {}): HostRegistration {
return {
kind: 'maka-runtime-host' as const,
schemaVersion: RUNTIME_HOST_REGISTRATION_SCHEMA_VERSION,
Expand Down
Loading