1package provider
2
3import (
4 "context"
5 "testing"
6)
7
8func TestCopilotCatalogCoversPublicChatModels(t *testing.T) {
9 groups := map[string][]string{
10 APIAnthropicMessages: {"claude-fable-5", "claude-fable-5.1", "claude-haiku-4.5", "claude-opus-4.7", "claude-opus-4.8", "claude-opus-4.8-fast", "claude-opus-5", "claude-sonnet-5"},
11 APIResponses: {"gpt-5-mini", "gpt-5.3-codex", "gpt-5.4", "gpt-5.4-mini", "gpt-5.5", "gpt-5.6-luna", "gpt-5.6-sol", "gpt-5.6-terra", "gpt-6-astra", "grok-4.5", "grok-4.6", "mai-code-1-flash-picker", "mai-code-1.1-flash"},
12 APICompletions: {"gemini-3.5-flash", "gemini-3.6-flash", "gemini-3.7-flash", "gemini-3.8-flash", "kimi-k2.7-code", "kimi-k3"},
13 }
14 for api, ids := range groups {
15 for _, id := range ids {
16 t.Run(id, func(t *testing.T) {
17 m, err := FindModel("github-copilot", id)
18 if err != nil {
19 t.Fatal(err)
20 }
21 if m.API != api {
22 t.Fatalf("API = %q, want %q", m.API, api)
23 }
24 if m.ContextWindow <= 0 || m.MaxOutput <= 0 || m.MaxOutput >= m.ContextWindow {
25 t.Fatalf("invalid context/output limits: %d/%d", m.ContextWindow, m.MaxOutput)
26 }
27 if m.BaseURL != copilotDefaultBaseURL || !m.Reasoning {
28 t.Fatal("invalid endpoint or reasoning metadata")
29 }
30 client := NewGithubCopilotClient("synthetic-token").(*copilotClient)
31 captures := make(map[string]*routeCaptureClient)
32 for _, key := range []string{APIAnthropicMessages, APIResponses, APICompletions} {
33 capture := &routeCaptureClient{name: "github-copilot"}
34 captures[key] = capture
35 client.router.byAPI[key] = capture
36 }
37 stream, err := client.Stream(context.Background(), Request{Model: id})
38 if err != nil {
39 t.Fatal(err)
40 }
41 for range stream {
42 }
43 for key, capture := range captures {
44 want := 0
45 if key == api {
46 want = 1
47 }
48 if len(capture.models) != want {
49 t.Errorf("%s routed to %s incorrectly", id, key)
50 }
51 }
52 })
53 }
54 }
55}
56
57func TestCopilotCatalogExcludesRetiredAndUtilityModels(t *testing.T) {
58 // https://docs.github.com/en/copilot/reference/ai-models/supported-models
59 // Sonnet 4.6 is excluded from the general catalog despite its annual-plan exception.
60 excluded := map[string]bool{
61 "claude-opus-4.5": true, "claude-opus-4.6": true,
62 "claude-sonnet-4.5": true, "claude-sonnet-4.6": true,
63 "gemini-2.5-pro": true, "gemini-3-flash-preview": true, "gemini-3.1-pro-preview": true,
64 "gpt-4.1": true, "gpt-4o": true, "gpt-5.2": true, "gpt-5.2-codex": true,
65 "grok-code-fast-1": true, "gpt-5.4-nano": true,
66 }
67 for _, m := range Catalog {
68 if m.Provider == "github-copilot" && excluded[m.ID] {
69 t.Errorf("Copilot catalog still includes %q", m.ID)
70 }
71 }
72}