g1t/services/runner/src/hosted.test.ts
| 1 | import assert from "node:assert/strict"; |
| 2 | import { test } from "node:test"; |
| 3 | |
| 4 | import { hostedOpen, listedWorkspaces } from "./hosted.ts"; |
| 5 | |
| 6 | const live = { enabled: true, live: true }; |
| 7 | const testMode = { enabled: true, live: false }; |
| 8 | const none = { enabled: false, live: false }; |
| 9 | |
| 10 | test("listed workspaces use hosted models whatever billing is", () => { |
| 11 | assert.equal(hostedOpen("flagon-io", "flagon-io", testMode), true); |
| 12 | assert.equal(hostedOpen("Flagon-IO", " flagon-io , acme", none), true); |
| 13 | assert.equal(hostedOpen("anyone", "*", testMode), true); |
| 14 | }); |
| 15 | |
| 16 | test("with a test key a card check opens nothing: other workspaces bring their own provider", () => { |
| 17 | assert.equal(hostedOpen("acme", "flagon-io", testMode), false); |
| 18 | assert.equal(hostedOpen("acme", "flagon-io", none), false); |
| 19 | assert.equal(hostedOpen("acme", "", testMode), false); |
| 20 | }); |
| 21 | |
| 22 | test("once billing takes real money, every workspace may use them", () => { |
| 23 | assert.equal(hostedOpen("acme", "flagon-io", live), true); |
| 24 | }); |
| 25 | |
| 26 | test("the setting is a comma-separated list", () => { |
| 27 | assert.deepEqual(listedWorkspaces(" a, B ,,*"), ["a", "b", "*"]); |
| 28 | }); |