(t *testing.T)
| 1197 | } |
| 1198 | |
| 1199 | func TestListModelsWithCustomHandler(t *testing.T) { |
| 1200 | customModels := []ModelInfo{ |
| 1201 | { |
| 1202 | ID: "my-custom-model", |
| 1203 | Name: "My Custom Model", |
| 1204 | Capabilities: ModelCapabilities{ |
| 1205 | Supports: ModelSupports{Vision: false, ReasoningEffort: false}, |
| 1206 | Limits: ModelLimits{MaxContextWindowTokens: Int(128000)}, |
| 1207 | }, |
| 1208 | }, |
| 1209 | } |
| 1210 | |
| 1211 | callCount := 0 |
| 1212 | handler := func(ctx context.Context) ([]ModelInfo, error) { |
| 1213 | callCount++ |
| 1214 | return customModels, nil |
| 1215 | } |
| 1216 | |
| 1217 | client := NewClient(&ClientOptions{OnListModels: handler}) |
| 1218 | |
| 1219 | models, err := client.ListModels(t.Context()) |
| 1220 | if err != nil { |
| 1221 | t.Fatalf("ListModels failed: %v", err) |
| 1222 | } |
| 1223 | if callCount != 1 { |
| 1224 | t.Errorf("expected handler called once, got %d", callCount) |
| 1225 | } |
| 1226 | if len(models) != 1 || models[0].ID != "my-custom-model" { |
| 1227 | t.Errorf("unexpected models: %+v", models) |
| 1228 | } |
| 1229 | } |
| 1230 | |
| 1231 | func TestModelBillingTokenPricesJSON(t *testing.T) { |
| 1232 | int64Ptr := func(v int64) *int64 { |
nothing calls this directly
no test coverage detected
searching dependent graphs…