fixes
This commit is contained in:
@@ -115,6 +115,38 @@ func TestResolveAIConfig_envFallback(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestResolveAIConfig_dbPreferredOverMockEnv(t *testing.T) {
|
||||
key := DeriveKey("test-ai-config-secret-material", "fallback")
|
||||
plain := "sk-db-overloaded-key"
|
||||
enc, err := EncryptSecret(key, plain)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
svc := &Service{
|
||||
Key: key,
|
||||
Env: EnvConfig{
|
||||
OpenAIAPIKey: "sk-mock-env",
|
||||
OpenAIBaseURL: "http://127.0.0.1:18767/v1",
|
||||
OpenAIModel: "mock-llm",
|
||||
},
|
||||
}
|
||||
doc := storedDoc{
|
||||
OpenAI: openaiStored{
|
||||
BaseURL: "https://llm.overloadedbot.org/v1",
|
||||
Model: "code-fast",
|
||||
APIKeyEnc: enc,
|
||||
APIKeyLast4: last4(plain),
|
||||
},
|
||||
}
|
||||
got, err := svc.resolveLegacyOpenAI(doc)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got.Source != SourceDB || got.APIKey != plain || got.BaseURL != "https://llm.overloadedbot.org/v1" || got.Model != "code-fast" {
|
||||
t.Fatalf("legacy resolve should prefer DB over mock env: %+v", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPatchAIExtras(t *testing.T) {
|
||||
var extras map[string]string
|
||||
val := "1536"
|
||||
|
||||
Reference in New Issue
Block a user