thread-master/internal/library/placement/source_mode_test.go

42 lines
1.4 KiB
Go
Raw Permalink Normal View History

2026-06-26 08:37:04 +00:00
package placement
import "testing"
func TestWithoutCrawlerStripsBrowserModes(t *testing.T) {
if got := WithoutCrawler(SearchSourceMixed); got != SearchSourceThreadsBrave {
t.Fatalf("mixed -> threads_brave, got %s", got)
}
if got := WithoutCrawler(SearchSourceCrawler); got != SearchSourceThreads {
t.Fatalf("crawler -> threads, got %s", got)
}
}
func TestMemberNeedsBraveKey(t *testing.T) {
threadsOnly := MemberContext{AllowsBrave: false, AllowsThreadsAPI: true, SearchSourceMode: SearchSourceThreads}
if MemberNeedsBraveKey(threadsOnly) {
t.Fatal("threads-only should not require brave key")
}
braveOnly := MemberContext{AllowsBrave: true, SearchSourceMode: SearchSourceBrave}
if !MemberNeedsBraveKey(braveOnly) {
t.Fatal("brave-only should require brave key")
}
devCrawler := MemberContext{AllowsBrave: true, DevMode: true, SearchSourceMode: SearchSourceCrawler}
if MemberNeedsBraveKey(devCrawler) {
t.Fatal("dev crawler should not require brave key")
}
}
func TestBuildMemberContextFormalModeRespectsSearchSource(t *testing.T) {
prefs := ConnectionPrefsInput{
DevMode: false,
SearchSourceMode: string(SearchSourceMixed),
}
ctx := BuildMemberContext("t", "u", "acc", prefs, true, false, ResearchSettings{}, false, 10)
if !ctx.AllowsCrawler {
t.Fatal("mixed mode should allow crawler when browser is connected")
}
if ctx.SearchSourceMode != SearchSourceMixed {
t.Fatalf("expected mixed, got %s", ctx.SearchSourceMode)
}
}