|
1 | 1 | import { assertEquals } from "jsr:@std/assert@^1.0.0"; |
2 | | -import { resolveContextLimit } from "./context-limit.ts"; |
| 2 | +import { |
| 3 | + type ContextLimitCacheEntry, |
| 4 | + resolveContextLimit, |
| 5 | +} from "./context-limit.ts"; |
3 | 6 |
|
4 | 7 | Deno.test("resolveContextLimit re-probes after fallback cache expiry", async () => { |
5 | 8 | let now = 100_000; |
6 | | - const cache = new Map< |
7 | | - string, |
8 | | - number | { value: number; expiresAt?: number } |
9 | | - >(); |
| 9 | + const cache = new Map<string, ContextLimitCacheEntry>(); |
10 | 10 | let calls = 0; |
11 | 11 | const client = { |
12 | 12 | provider: { |
@@ -70,10 +70,7 @@ Deno.test("resolveContextLimit re-probes after fallback cache expiry", async () |
70 | 70 |
|
71 | 71 | Deno.test("resolveContextLimit keeps fallback caches scoped per normalized directory until expiry", async () => { |
72 | 72 | let now = 200_000; |
73 | | - const cache = new Map< |
74 | | - string, |
75 | | - number | { value: number; expiresAt?: number } |
76 | | - >(); |
| 73 | + const cache = new Map<string, ContextLimitCacheEntry>(); |
77 | 74 | const calls: string[] = []; |
78 | 75 | const client = { |
79 | 76 | provider: { |
@@ -158,10 +155,7 @@ Deno.test("resolveContextLimit keeps fallback caches scoped per normalized direc |
158 | 155 | }); |
159 | 156 |
|
160 | 157 | Deno.test("resolveContextLimit keeps positive cache entries without expiry re-probes", async () => { |
161 | | - const cache = new Map< |
162 | | - string, |
163 | | - number | { value: number; expiresAt?: number } |
164 | | - >(); |
| 158 | + const cache = new Map<string, ContextLimitCacheEntry>(); |
165 | 159 | let calls = 0; |
166 | 160 | const client = { |
167 | 161 | provider: { |
@@ -204,10 +198,7 @@ Deno.test("resolveContextLimit keeps positive cache entries without expiry re-pr |
204 | 198 | }); |
205 | 199 |
|
206 | 200 | Deno.test("resolveContextLimit re-probes when legacy numeric cache entry is non-positive", async () => { |
207 | | - const cache = new Map< |
208 | | - string, |
209 | | - number | { value: number; expiresAt?: number } |
210 | | - >(); |
| 201 | + const cache = new Map<string, ContextLimitCacheEntry>(); |
211 | 202 | cache.set("openai/gpt-5", -1); |
212 | 203 |
|
213 | 204 | let calls = 0; |
@@ -243,10 +234,7 @@ Deno.test("resolveContextLimit re-probes when legacy numeric cache entry is non- |
243 | 234 | }); |
244 | 235 |
|
245 | 236 | Deno.test("resolveContextLimit re-probes when legacy object cache entry is non-positive without expiry", async () => { |
246 | | - const cache = new Map< |
247 | | - string, |
248 | | - number | { value: number; expiresAt?: number } |
249 | | - >(); |
| 237 | + const cache = new Map<string, ContextLimitCacheEntry>(); |
250 | 238 | cache.set("openai/gpt-5", { value: -1 }); |
251 | 239 |
|
252 | 240 | let calls = 0; |
|
0 commit comments