(t *testing.T)
| 1301 | } |
| 1302 | |
| 1303 | func TestListModelsHandlerCachesResults(t *testing.T) { |
| 1304 | customModels := []ModelInfo{ |
| 1305 | { |
| 1306 | ID: "cached-model", |
| 1307 | Name: "Cached Model", |
| 1308 | Capabilities: ModelCapabilities{ |
| 1309 | Supports: ModelSupports{Vision: false, ReasoningEffort: false}, |
| 1310 | Limits: ModelLimits{MaxContextWindowTokens: Int(128000)}, |
| 1311 | }, |
| 1312 | }, |
| 1313 | } |
| 1314 | |
| 1315 | callCount := 0 |
| 1316 | handler := func(ctx context.Context) ([]ModelInfo, error) { |
| 1317 | callCount++ |
| 1318 | return customModels, nil |
| 1319 | } |
| 1320 | |
| 1321 | client := NewClient(&ClientOptions{OnListModels: handler}) |
| 1322 | |
| 1323 | _, _ = client.ListModels(t.Context()) |
| 1324 | _, _ = client.ListModels(t.Context()) |
| 1325 | if callCount != 1 { |
| 1326 | t.Errorf("expected handler called once due to caching, got %d", callCount) |
| 1327 | } |
| 1328 | } |
| 1329 | |
| 1330 | func TestClient_StartContextCancellationDoesNotKillProcess(t *testing.T) { |
| 1331 | cliPath := findCLIPathForTest() |
nothing calls this directly
no test coverage detected
searching dependent graphs…