Skip to content

Commit e51a880

Browse files
committed
test(remote): check the platform the allocator is asked for, not just the flags
The case named "never sends apple" only read the returned flag. The lease request is the thing a provider acts on, so the claim was pinned one layer away from the surface that had to hold. Each command now keeps its allocate handle: the guarded case asserts the request the provider received names `macos` rather than the `apple` the record still held, and the refused case asserts no request was made at all. Verified by mutation: letting the recorded alias survive into the materialized state fails on the leaf assertion, and an earlier test catches it too.
1 parent 65abe33 commit e51a880

1 file changed

Lines changed: 20 additions & 6 deletions

File tree

‎src/__tests__/remote-connection-platform-axis.test.ts‎

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -660,12 +660,18 @@ test('an undecided record narrows to the requested leaf or refuses, and never se
660660
'agent-device-connect-undecided-leaf-',
661661
);
662662
fs.writeFileSync(remoteConfigPath, JSON.stringify({ daemonBaseUrl: 'https://daemon.example' }));
663+
const allocations: ReturnType<typeof recordedLeaseAllocate>[] = [];
663664
const command = (
664665
session: string,
665666
leaseBackend: 'ios-simulator' | 'ios-instance',
666667
platform: 'apple' | 'macos',
667-
) =>
668-
materializeRemoteConnectionForCommand({
668+
) => {
669+
const allocation = recordedLeaseAllocate({
670+
leaseId: 'undecided-lease-1',
671+
backend: leaseBackend,
672+
});
673+
allocations.push(allocation);
674+
return materializeRemoteConnectionForCommand({
669675
command: 'snapshot',
670676
flags: {
671677
json: true,
@@ -679,11 +685,9 @@ test('an undecided record narrows to the requested leaf or refuses, and never se
679685
session,
680686
platform,
681687
},
682-
client: createTestClient({
683-
allocate: recordedLeaseAllocate({ leaseId: 'undecided-lease-1', backend: leaseBackend })
684-
.stub,
685-
}),
688+
client: createTestClient({ allocate: allocation.stub }),
686689
});
690+
};
687691

688692
seedConnectionState({
689693
stateDir,
@@ -703,6 +707,11 @@ test('an undecided record narrows to the requested leaf or refuses, and never se
703707
'macos',
704708
'a runner guard rents no leaf, so the request keeps its own',
705709
);
710+
assert.equal(
711+
allocations[0]?.request?.platform,
712+
'macos',
713+
'the lease request the provider sees names the leaf, not the family the record held',
714+
);
706715

707716
seedConnectionState({
708717
stateDir,
@@ -725,6 +734,11 @@ test('an undecided record narrows to the requested leaf or refuses, and never se
725734
error.details?.requestedPlatform === 'macos',
726735
'a backend that rents iOS is a bound device, alias or no alias',
727736
);
737+
assert.equal(
738+
allocations[1]?.request,
739+
undefined,
740+
'the refused request never reached the allocator with a platform to name',
741+
);
728742
fs.rmSync(tempRoot, { recursive: true, force: true });
729743
});
730744

0 commit comments

Comments
 (0)