secert updated

This commit is contained in:
2026-09-24 17:20:04 +05:30
parent 299871b820
commit 00317a00d8
11 changed files with 517 additions and 81 deletions

View File

@@ -2,7 +2,6 @@ package services
import (
"context"
"os"
"strings"
"testing"
"time"
@@ -41,23 +40,14 @@ import (
func liveChat(t *testing.T) (utils.Chat, string) {
t.Helper()
// Provider defaults exactly as production does, so this exercises the
// defaulting rather than working around it. The first version read the
// variable straight and skipped silently the moment `ASSISTANT_PROVIDER`
// was left unset — which is precisely the configuration this is meant to
// prove works.
provider := strings.ToLower(strings.TrimSpace(os.Getenv("ASSISTANT_PROVIDER")))
model := os.Getenv("ASSISTANT_MODEL")
if provider == "" && strings.TrimSpace(model) != "" {
provider = "openai"
}
cfg := config.AssistantConfig{
Provider: provider,
BaseURL: os.Getenv("ASSISTANT_BASE_URL"),
APIKey: os.Getenv("ASSISTANT_API_KEY"),
Balanced: model,
}
// Read exactly as production reads it, defaults and all.
//
// This was a hand-built struct twice, and it was wrong both times: first it
// read ASSISTANT_PROVIDER straight and skipped silently once that stopped
// being required, then it kept demanding ASSISTANT_MODEL after that gained
// a default. A test that builds its own configuration is a test of a
// configuration nobody runs.
cfg := config.AssistantFromEnv()
if !cfg.Enabled() {
t.Skipf("no model configured, skipping the live test: %s", cfg.Why())
}