(t *testing.T)
| 153 | } |
| 154 | |
| 155 | func TestLoadFromString(t *testing.T) { |
| 156 | _ = os.Setenv("API_KEY", "sk-test-key") |
| 157 | defer func() { _ = os.Unsetenv("API_KEY") }() |
| 158 | |
| 159 | loader := NewLoader() |
| 160 | |
| 161 | content := ` |
| 162 | model_config: |
| 163 | provider: "anthropic" |
| 164 | api_key: "${API_KEY}" |
| 165 | model: "claude-3-5-sonnet" |
| 166 | ` |
| 167 | |
| 168 | var result struct { |
| 169 | ModelConfig struct { |
| 170 | Provider string `yaml:"provider"` |
| 171 | APIKey string `yaml:"api_key"` |
| 172 | Model string `yaml:"model"` |
| 173 | } `yaml:"model_config"` |
| 174 | } |
| 175 | |
| 176 | err := loader.LoadFromString(content, &result) |
| 177 | if err != nil { |
| 178 | t.Fatalf("LoadFromString failed: %v", err) |
| 179 | } |
| 180 | |
| 181 | if result.ModelConfig.Provider != "anthropic" { |
| 182 | t.Errorf("expected provider 'anthropic', got %q", result.ModelConfig.Provider) |
| 183 | } |
| 184 | if result.ModelConfig.APIKey != "sk-test-key" { |
| 185 | t.Errorf("expected api_key 'sk-test-key', got %q", result.ModelConfig.APIKey) |
| 186 | } |
| 187 | if result.ModelConfig.Model != "claude-3-5-sonnet" { |
| 188 | t.Errorf("expected model 'claude-3-5-sonnet', got %q", result.ModelConfig.Model) |
| 189 | } |
| 190 | } |
| 191 | |
| 192 | func TestLoadAgentConfig(t *testing.T) { |
| 193 | // Create a temp file |
nothing calls this directly
no test coverage detected