From d8a8f1b9176d5bf52947573565e1073d53402bc6 Mon Sep 17 00:00:00 2001 From: daikaginza Date: Sat, 24 Oct 2026 13:38:30 +0700 Subject: [PATCH] test(opensky): fail the retired-route case if it reaches any upstream The stub answered every URL, so the case still passed had the military route started fetching again while still answering 503. It now counts non-OpenSky calls and requires zero. --- src/openSkyTrackGovernor.test.mjs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/openSkyTrackGovernor.test.mjs b/src/openSkyTrackGovernor.test.mjs index 4ced3e33da..41e86c7524 100644 --- a/src/openSkyTrackGovernor.test.mjs +++ b/src/openSkyTrackGovernor.test.mjs @@ -147,7 +147,12 @@ test('each client gets its own quota rather than sharing one bucket', async (t) }); test('the retired military route is not metered, so the OpenSky limiter never reaches it', async (t) => { - stubFetch(t, async () => trackOk()); + let militaryUpstreamCalls = 0; + stubFetch(t, async (url) => { + if (String(url).includes('/tracks/all')) return trackOk(); + militaryUpstreamCalls += 1; + return new Response('{"trace":[]}', { status: 200 }); + }); const routes = install(trackBackfillProxies()); const track = routes.get('/api/flights/track'); const trace = routes.get('/api/military/track'); @@ -166,6 +171,7 @@ test('the retired military route is not metered, so the OpenSky limiter never re }); assert.equal(military.statusCode, 503); } + assert.equal(militaryUpstreamCalls, 0, 'the refusal makes no upstream call'); }); test('a 429 from /tracks stands every other icao24 down until it clears', async (t) => {