haixunMaster/haixun-backend/internal/library/placement/effective_strategy_test.go

39 lines
1.1 KiB
Go
Raw Permalink Normal View History

2026-06-25 08:20:03 +00:00
package placement
import (
"testing"
libkg "haixun-backend/internal/library/knowledge"
)
func TestEffectiveExpandStrategyFallsBackToLLMWithoutKey(t *testing.T) {
research := ResearchSettings{
ExpandStrategy: string(libkg.ExpandStrategyBrave),
WebSearchProvider: "brave",
BraveAPIKey: "",
}
if got := EffectiveExpandStrategy(research); got != libkg.ExpandStrategyLLM {
t.Fatalf("expected llm fallback, got %s", got)
}
}
func TestEffectiveExpandStrategyKeepsBraveWithKey(t *testing.T) {
research := ResearchSettings{
ExpandStrategy: string(libkg.ExpandStrategyBrave),
WebSearchProvider: "brave",
BraveAPIKey: "test-key",
}
if got := EffectiveExpandStrategy(research); got != libkg.ExpandStrategyBrave {
t.Fatalf("expected brave, got %s", got)
}
}
func TestWebSearchAvailable(t *testing.T) {
if WebSearchAvailable(ResearchSettings{WebSearchProvider: "brave"}) {
t.Fatal("expected unavailable without brave key")
}
if !WebSearchAvailable(ResearchSettings{WebSearchProvider: "brave", BraveAPIKey: "k"}) {
t.Fatal("expected available with brave key")
}
2026-06-25 09:34:28 +00:00
}