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

27 lines
835 B
Go

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 TestBuildMemberContextFormalModeNeverAllowsCrawler(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("formal mode must not allow crawler")
}
if ctx.SearchSourceMode != SearchSourceThreadsBrave {
t.Fatalf("expected threads_brave, got %s", ctx.SearchSourceMode)
}
}