Skip to content

Commit b1f65c4

Browse files
thymikeeclaude
andcommitted
test(daemon): prove the refused provider lease recorded nothing without a lease registry handle
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
1 parent 86d3a4c commit b1f65c4

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

‎test/integration/provider-scenarios/provider-device-runtime.test.ts‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import fs from 'node:fs';
33
import path from 'node:path';
44
import { test } from 'vitest';
55
import type { DeviceLease } from '@agent-device/contracts/device';
6-
import { LeaseRegistry } from '@agent-device/daemon/testing/lease-registry';
76
import { assertRpcError, assertRpcOk } from './assertions.ts';
87
import {
98
createProviderScenarioHarness,
@@ -91,12 +90,13 @@ test('provider-owned iOS simulators relaunch without local CoreSimulator refresh
9190
});
9291

9392
test('provider lease allocation is refused when no registered runtime claims the provider', async () => {
94-
const leaseRegistry = new LeaseRegistry();
9593
const daemon = await createProviderScenarioHarness({
9694
providerRuntimeIds: [FAKE_PROVIDER],
97-
leaseRegistry,
9895
deviceInventoryProvider: async () => null,
9996
});
97+
// A daemon never reuses an id it issued, so naming the refused lease's id again proves no lease
98+
// was recorded.
99+
const leaseId = 'abcdef0123456789abcdef0123456789';
100100
try {
101101
const response = await daemon.callCommand(
102102
'lease_allocate',
@@ -106,6 +106,7 @@ test('provider lease allocation is refused when no registered runtime claims the
106106
meta: {
107107
tenantId: 'team-a',
108108
runId: 'run-a',
109+
leaseId,
109110
leaseBackend: 'ios-instance',
110111
leaseProvider: 'testmu',
111112
},
@@ -122,7 +123,13 @@ test('provider lease allocation is refused when no registered runtime claims the
122123
assert.equal(details.provider, 'testmu');
123124
assert.deepEqual(details.registeredProviders, [FAKE_PROVIDER]);
124125
assert.match(String(error.hint), /Restart the daemon/);
125-
assert.deepEqual(leaseRegistry.listActiveLeases(), []);
126+
const retried = await daemon.callCommand(
127+
'lease_allocate',
128+
[],
129+
{ tenant: 'team-a', runId: 'run-a' },
130+
{ meta: { tenantId: 'team-a', runId: 'run-a', leaseId } },
131+
);
132+
assert.equal(assertRpcOk<{ lease: DeviceLease }>(retried).lease.leaseId, leaseId);
126133
} finally {
127134
await daemon.close();
128135
}

0 commit comments

Comments
 (0)