Unified Agent + reusable Go agent core.
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix

Lyric 70f024a0 a5c7d6c3

+37
+37
cmd/mistermorph/consolecmd/agent_settings_test.go
··· 16 16 "github.com/spf13/viper" 17 17 ) 18 18 19 + func unsetManagedLLMEnv(t *testing.T) { 20 + t.Helper() 21 + for _, name := range []string{ 22 + "MISTER_MORPH_LLM_PROVIDER", 23 + "MISTER_MORPH_LLM_ENDPOINT", 24 + "MISTER_MORPH_LLM_API_KEY", 25 + "MISTER_MORPH_LLM_MODEL", 26 + "MISTER_MORPH_LLM_AZURE_DEPLOYMENT", 27 + "MISTER_MORPH_LLM_REASONING_EFFORT", 28 + "MISTER_MORPH_LLM_TOOLS_EMULATION_MODE", 29 + "MISTER_MORPH_LLM_CLOUDFLARE_ACCOUNT_ID", 30 + "MISTER_MORPH_LLM_CLOUDFLARE_API_TOKEN", 31 + } { 32 + prev, had := os.LookupEnv(name) 33 + if err := os.Unsetenv(name); err != nil { 34 + t.Fatalf("Unsetenv(%q) error = %v", name, err) 35 + } 36 + t.Cleanup(func() { 37 + if had { 38 + _ = os.Setenv(name, prev) 39 + } else { 40 + _ = os.Unsetenv(name) 41 + } 42 + }) 43 + } 44 + } 45 + 19 46 func TestReadAgentSettings(t *testing.T) { 20 47 configPath := filepath.Join(t.TempDir(), "config.yaml") 21 48 if err := os.WriteFile(configPath, []byte( ··· 921 948 } 922 949 923 950 func TestHandleAgentSettingsGetIncludesProfileEnvManagedPlaceholders(t *testing.T) { 951 + unsetManagedLLMEnv(t) 952 + 924 953 configPath := filepath.Join(t.TempDir(), "config.yaml") 925 954 if err := os.WriteFile(configPath, []byte( 926 955 "llm:\n provider: openai\n model: ${OPENAI_MODEL}\n api_key: ${OPENAI_API_KEY}\n profiles:\n cheap:\n model: ${CHEAP_MODEL}\n edge:\n provider: cloudflare\n cloudflare:\n account_id: ${CF_ACCOUNT_ID}\n api_token: ${CF_API_TOKEN}\n", ··· 1120 1149 } 1121 1150 1122 1151 func TestHandleAgentSettingsModelsFallsBackToRuntimeAPIKey(t *testing.T) { 1152 + unsetManagedLLMEnv(t) 1153 + 1123 1154 upstream := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { 1124 1155 if got := r.Header.Get("Authorization"); got != "Bearer sk-runtime" { 1125 1156 t.Fatalf("authorization = %q, want Bearer sk-runtime", got) ··· 1202 1233 } 1203 1234 1204 1235 func TestHandleAgentSettingsTestFallsBackToRuntimeConfig(t *testing.T) { 1236 + unsetManagedLLMEnv(t) 1237 + 1205 1238 prev := runAgentSettingsConnectionTest 1206 1239 prevLLM, hadLLM := viper.Get("llm"), viper.IsSet("llm") 1207 1240 viper.Set("llm", map[string]any{ ··· 1256 1289 } 1257 1290 1258 1291 func TestHandleAgentSettingsTestFallsBackToRuntimeCloudflareToken(t *testing.T) { 1292 + unsetManagedLLMEnv(t) 1293 + 1259 1294 prev := runAgentSettingsConnectionTest 1260 1295 prevLLM, hadLLM := viper.Get("llm"), viper.IsSet("llm") 1261 1296 viper.Set("llm", map[string]any{ ··· 1370 1405 } 1371 1406 1372 1407 func TestHandleAgentSettingsTestTreatsEmptyTargetProfileAsDefaultFallback(t *testing.T) { 1408 + unsetManagedLLMEnv(t) 1409 + 1373 1410 prev := runAgentSettingsConnectionTest 1374 1411 prevLLM, hadLLM := viper.Get("llm"), viper.IsSet("llm") 1375 1412 viper.Set("llm", map[string]any{