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

42 lines
1.1 KiB
Go

package placement
import "testing"
func TestShouldTryCrawlerFirst_mixedWithBrowser(t *testing.T) {
m := MemberContext{
AllowsCrawler: true,
BrowserConnected: true,
SearchSourceMode: SearchSourceMixed,
AllowsThreadsAPI: true,
ApiConnected: true,
}
if !ShouldTryCrawlerFirst(m) {
t.Fatal("mixed + browser should try crawler first to save API")
}
}
func TestShouldTryCrawlerFirst_threadsOnly(t *testing.T) {
m := MemberContext{
AllowsCrawler: true,
BrowserConnected: true,
SearchSourceMode: SearchSourceThreads,
}
if ShouldTryCrawlerFirst(m) {
t.Fatal("threads-only must not use crawler first")
}
}
func TestBuildMemberContextFormalModeKeepsCrawlerMode(t *testing.T) {
prefs := ConnectionPrefsInput{
DevMode: false,
SearchSourceMode: string(SearchSourceThreadsCrawler),
}
ctx := BuildMemberContext("t", "u", "acc", prefs, true, true, ResearchSettings{}, false, 10)
if !ctx.AllowsCrawler {
t.Fatal("threads_crawler in formal mode should allow crawler")
}
if !ctx.AllowsThreadsAPI {
t.Fatal("threads_crawler should still allow API fallback")
}
}