MCPcopy Create free account
hub / github.com/astercloud/aster / TestLoadFromString

Function TestLoadFromString

pkg/config/loader_test.go:155–190  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

153}
154
155func 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 := `
162model_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
192func TestLoadAgentConfig(t *testing.T) {
193 // Create a temp file

Callers

nothing calls this directly

Calls 2

LoadFromStringMethod · 0.95
NewLoaderFunction · 0.70

Tested by

no test coverage detected