| 1 | package boot |
| 2 | |
| 3 | import ( |
| 4 | "testing" |
| 5 | |
| 6 | "reasonix/internal/config" |
| 7 | "reasonix/internal/provider" |
| 8 | ) |
| 9 | |
| 10 | func TestRemoteResolverMetadataOverridesHostProviderWithSameRef(t *testing.T) { |
| 11 | cfg := &config.Config{Providers: []config.ProviderEntry{{ |
| 12 | Name: "shared", Kind: "openai", Model: "model", ContextWindow: 64_000, |
| 13 | Price: &provider.Pricing{Input: 9, Output: 9, Currency: "host"}, |
| 14 | }}} |
| 15 | resolver := &provider.StaticResolver{Descriptors: []provider.Descriptor{{ |
| 16 | Ref: "shared/model", DisplayName: "shared", Model: "model", |
| 17 | ContextWindow: 1_000_000, PricingCurrency: "$", |
| 18 | CacheHitPerMillion: 0.1, InputPerMillion: 1.25, OutputPerMillion: 4.5, |
| 19 | }}} |
| 20 | |
| 21 | entry, ref, err := resolveModelEntry(resolver, cfg, "shared/model") |
| 22 | if err != nil { |
| 23 | t.Fatal(err) |
| 24 | } |
| 25 | if ref != "shared/model" || entry.ContextWindow != 1_000_000 { |
| 26 | t.Fatalf("resolved ref/context = %q/%d", ref, entry.ContextWindow) |
| 27 | } |
| 28 | if entry.Price == nil || entry.Price.CacheHit != 0.1 || entry.Price.Input != 1.25 || entry.Price.Output != 4.5 || entry.Price.Currency != "$" { |
| 29 | t.Fatalf("resolved pricing = %+v", entry.Price) |
| 30 | } |
| 31 | } |
| 32 |