From f50e1e801556ad2219d8c6df3819c45a4218b7f2 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Mon, 16 Feb 2026 01:15:35 +0000 Subject: [PATCH] perf(test): fold gateway discover tests into run-loop --- src/cli/gateway-cli/discover.test.ts | 35 ---------------------------- src/cli/gateway-cli/run-loop.test.ts | 34 +++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 35 deletions(-) delete mode 100644 src/cli/gateway-cli/discover.test.ts diff --git a/src/cli/gateway-cli/discover.test.ts b/src/cli/gateway-cli/discover.test.ts deleted file mode 100644 index bda8b70920b..00000000000 --- a/src/cli/gateway-cli/discover.test.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { describe, expect, it } from "vitest"; -import type { GatewayBonjourBeacon } from "../../infra/bonjour-discovery.js"; -import { pickBeaconHost, pickGatewayPort } from "./discover.js"; - -describe("gateway discover routing helpers", () => { - it("prefers resolved service host over TXT hints", () => { - const beacon: GatewayBonjourBeacon = { - instanceName: "Test", - host: "10.0.0.2", - lanHost: "evil.example.com", - tailnetDns: "evil.example.com", - }; - expect(pickBeaconHost(beacon)).toBe("10.0.0.2"); - }); - - it("prefers resolved service port over TXT gatewayPort", () => { - const beacon: GatewayBonjourBeacon = { - instanceName: "Test", - host: "10.0.0.2", - port: 18789, - gatewayPort: 12345, - }; - expect(pickGatewayPort(beacon)).toBe(18789); - }); - - it("falls back to TXT host/port when resolve data is missing", () => { - const beacon: GatewayBonjourBeacon = { - instanceName: "Test", - lanHost: "test-host.local", - gatewayPort: 18789, - }; - expect(pickBeaconHost(beacon)).toBe("test-host.local"); - expect(pickGatewayPort(beacon)).toBe(18789); - }); -}); diff --git a/src/cli/gateway-cli/run-loop.test.ts b/src/cli/gateway-cli/run-loop.test.ts index 83d61c97d9a..3bea291e24f 100644 --- a/src/cli/gateway-cli/run-loop.test.ts +++ b/src/cli/gateway-cli/run-loop.test.ts @@ -1,4 +1,6 @@ import { describe, expect, it, vi } from "vitest"; +import type { GatewayBonjourBeacon } from "../../infra/bonjour-discovery.js"; +import { pickBeaconHost, pickGatewayPort } from "./discover.js"; const acquireGatewayLock = vi.fn(async () => ({ release: vi.fn(async () => {}), @@ -140,3 +142,35 @@ describe("runGatewayLoop", () => { } }); }); + +describe("gateway discover routing helpers", () => { + it("prefers resolved service host over TXT hints", () => { + const beacon: GatewayBonjourBeacon = { + instanceName: "Test", + host: "10.0.0.2", + lanHost: "evil.example.com", + tailnetDns: "evil.example.com", + }; + expect(pickBeaconHost(beacon)).toBe("10.0.0.2"); + }); + + it("prefers resolved service port over TXT gatewayPort", () => { + const beacon: GatewayBonjourBeacon = { + instanceName: "Test", + host: "10.0.0.2", + port: 18789, + gatewayPort: 12345, + }; + expect(pickGatewayPort(beacon)).toBe(18789); + }); + + it("falls back to TXT host/port when resolve data is missing", () => { + const beacon: GatewayBonjourBeacon = { + instanceName: "Test", + lanHost: "test-host.local", + gatewayPort: 18789, + }; + expect(pickBeaconHost(beacon)).toBe("test-host.local"); + expect(pickGatewayPort(beacon)).toBe(18789); + }); +});