package placement

import "testing"

func TestMemberContextForAPIOnlyDisablesCrawler(t *testing.T) {
	base := BuildMemberContext(
		"t", "u", "acc",
		ConnectionPrefsInput{SearchSourceMode: string(SearchSourceMixed)},
		true, true, ResearchSettings{}, false, 10,
	)
	apiOnly := MemberContextForAPIOnly(base)
	if apiOnly.AllowsCrawler {
		t.Fatal("API-only context must not allow crawler")
	}
	if apiOnly.DevMode {
		t.Fatal("API-only context must not be dev mode")
	}
	if !apiOnly.AllowsThreadsAPI {
		t.Fatal("API-only context should keep Threads API")
	}
}

func TestMemberContextForCrawlerOnlyStillWorks(t *testing.T) {
	base := MemberContextForAPIOnly(BuildMemberContext(
		"t", "u", "acc",
		ConnectionPrefsInput{SearchSourceMode: string(SearchSourceMixed)},
		true, true, ResearchSettings{}, false, 10,
	))
	crawler := MemberContextForCrawlerOnly(base)
	if !crawler.AllowsCrawler || crawler.SearchSourceMode != SearchSourceCrawler {
		t.Fatal("test patrol should force crawler-only routing")
	}
}
