package placement

import "testing"

func TestReplyTargetRankPrefersGold(t *testing.T) {
	gold := ScanCandidate{Priority: "gold", PlacementScore: 10}
	recent := ScanCandidate{Priority: "recent", PlacementScore: 90}
	if replyTargetRank(recent) >= replyTargetRank(gold) {
		t.Fatalf("expected gold to outrank recent")
	}
}

func TestPickReplyTargetsRespectsLimit(t *testing.T) {
	posts := make([]ScanCandidate, 0, 15)
	for i := 0; i < 15; i++ {
		posts = append(posts, ScanCandidate{
			ExternalID: "id-" + string(rune('a'+i)),
			Priority:   "relevant",
		})
	}
	targets := pickReplyTargets(posts, 5)
	if len(targets) != 5 {
		t.Fatalf("expected 5 targets, got %d", len(targets))
	}
}
