| 1 | package config |
| 2 | |
| 3 | import "testing" |
| 4 | |
| 5 | func TestAppliesOfficialDeepSeekV4ProPersona(t *testing.T) { |
| 6 | t.Parallel() |
| 7 | tests := []struct { |
| 8 | name string |
| 9 | entry *ProviderEntry |
| 10 | want bool |
| 11 | }{ |
| 12 | { |
| 13 | name: "nil", |
| 14 | entry: nil, |
| 15 | want: false, |
| 16 | }, |
| 17 | { |
| 18 | name: "official pro", |
| 19 | entry: &ProviderEntry{ |
| 20 | Name: "deepseek", |
| 21 | BaseURL: "https://api.deepseek.com", |
| 22 | Model: "deepseek-v4-pro", |
| 23 | }, |
| 24 | want: true, |
| 25 | }, |
| 26 | { |
| 27 | name: "official anthropic pro", |
| 28 | entry: &ProviderEntry{ |
| 29 | Name: "deepseek", |
| 30 | Kind: "anthropic", |
| 31 | BaseURL: "https://api.deepseek.com/anthropic", |
| 32 | Model: "deepseek-v4-pro", |
| 33 | }, |
| 34 | want: true, |
| 35 | }, |
| 36 | { |
| 37 | name: "official flash", |
| 38 | entry: &ProviderEntry{ |
| 39 | Name: "deepseek", |
| 40 | BaseURL: "https://api.deepseek.com", |
| 41 | Model: "deepseek-v4-flash", |
| 42 | }, |
| 43 | want: false, |
| 44 | }, |
| 45 | { |
| 46 | name: "third party pro name", |
| 47 | entry: &ProviderEntry{ |
| 48 | Name: "novita", |
| 49 | BaseURL: "https://api.novita.ai/openai", |
| 50 | Model: "deepseek/deepseek-v4-pro", |
| 51 | }, |
| 52 | want: false, |
| 53 | }, |
| 54 | { |
| 55 | name: "empty model on official host", |
| 56 | entry: &ProviderEntry{ |
| 57 | Name: "deepseek", |
| 58 | BaseURL: "https://api.deepseek.com", |
| 59 | }, |
| 60 | want: false, |
| 61 | }, |
| 62 | } |
| 63 | for _, tt := range tests { |
| 64 | t.Run(tt.name, func(t *testing.T) { |
| 65 | t.Parallel() |
| 66 | if got := AppliesOfficialDeepSeekV4ProPersona(tt.entry); got != tt.want { |
| 67 | t.Fatalf("AppliesOfficialDeepSeekV4ProPersona() = %v, want %v", got, tt.want) |
| 68 | } |
| 69 | }) |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | func TestApplyOfficialDeepSeekV4ProPersonaPrependsOnce(t *testing.T) { |
| 74 | t.Parallel() |
| 75 | pro := &ProviderEntry{BaseURL: "https://api.deepseek.com", Model: "deepseek-v4-pro"} |
| 76 | got := ApplyOfficialDeepSeekV4ProPersona("You are Reasonix, a coding agent.", pro) |
| 77 | want := OfficialDeepSeekV4ProPersona + "\n\nYou are Reasonix, a coding agent." |
| 78 | if got != want { |
| 79 | t.Fatalf("prepend = %q, want %q", got, want) |
| 80 | } |
| 81 | if again := ApplyOfficialDeepSeekV4ProPersona(got, pro); again != want { |
| 82 | t.Fatalf("second apply duplicated persona:\n%s", again) |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | func TestApplyOfficialDeepSeekV4ProPersonaStripsForOtherModels(t *testing.T) { |
| 87 | t.Parallel() |
| 88 | pro := &ProviderEntry{BaseURL: "https://api.deepseek.com", Model: "deepseek-v4-pro"} |
| 89 | flash := &ProviderEntry{BaseURL: "https://api.deepseek.com", Model: "deepseek-v4-flash"} |
| 90 | withPersona := ApplyOfficialDeepSeekV4ProPersona("BASE", pro) |
| 91 | got := ApplyOfficialDeepSeekV4ProPersona(withPersona, flash) |
| 92 | if got != "BASE" { |
| 93 | t.Fatalf("flash should drop the official pro persona, got %q", got) |
| 94 | } |
| 95 | } |
| 96 | |
| 97 | func TestReasoningLanguageForEntryPinsOfficialProAutoToEnglish(t *testing.T) { |
| 98 | t.Parallel() |
| 99 | pro := &ProviderEntry{BaseURL: "https://api.deepseek.com", Model: "deepseek-v4-pro"} |
| 100 | flash := &ProviderEntry{BaseURL: "https://api.deepseek.com", Model: "deepseek-v4-flash"} |
| 101 | if got := ReasoningLanguageForEntry(pro, "auto"); got != "en" { |
| 102 | t.Fatalf("official pro auto = %q, want en", got) |
| 103 | } |
| 104 | if got := ReasoningLanguageForEntry(pro, "zh"); got != "zh" { |
| 105 | t.Fatalf("explicit zh must stay user-owned, got %q", got) |
| 106 | } |
| 107 | if got := ReasoningLanguageForEntry(flash, "auto"); got != "auto" { |
| 108 | t.Fatalf("flash auto = %q, want auto", got) |
| 109 | } |
| 110 | } |
| 111 |