| 1 | import { RemoteWorkspaceLaunchGate } from "../lib/remoteWorkspace"; |
| 2 | |
| 3 | let passed = 0; |
| 4 | let failed = 0; |
| 5 | function ok(value: boolean, label: string) { |
| 6 | if (value) { |
| 7 | process.stdout.write(` PASS ${label}\n`); |
| 8 | passed += 1; |
| 9 | } else { |
| 10 | process.stdout.write(` FAIL ${label}\n`); |
| 11 | failed += 1; |
| 12 | } |
| 13 | } |
| 14 | |
| 15 | console.log("\nRemote workspace launch generations"); |
| 16 | |
| 17 | const gate = new RemoteWorkspaceLaunchGate(); |
| 18 | const hostAFirst = gate.begin("host-a"); |
| 19 | const hostBFirst = gate.begin("host-b"); |
| 20 | |
| 21 | ok(gate.isCurrent("host-a", hostAFirst), "opening host B does not cancel host A"); |
| 22 | ok(gate.isCurrent("host-b", hostBFirst), "host B keeps its own current request"); |
| 23 | |
| 24 | const hostASecond = gate.begin("host-a"); |
| 25 | ok(!gate.isCurrent("host-a", hostAFirst), "a newer request supersedes the same host"); |
| 26 | ok(gate.isCurrent("host-a", hostASecond), "the latest same-host request stays current"); |
| 27 | ok(gate.isCurrent("host-b", hostBFirst), "superseding host A does not cancel host B"); |
| 28 | |
| 29 | console.log(`\n${passed} passed, ${failed} failed, ${passed + failed} total`); |
| 30 | if (failed > 0) process.exit(1); |
| 31 |