mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-11 19:03:43 +00:00
24 lines
1.0 KiB
Go
24 lines
1.0 KiB
Go
package domain
|
|
|
|
import "testing"
|
|
|
|
func TestCasualLineupUsesBotsOnlyForMissingSlotsAndRequiresBothTeams(t *testing.T) {
|
|
lineup, err := BuildCasualLineup([]ConnectParticipant{{PlayerID: "p2", Team: 1}, {PlayerID: "p1", Team: 0}})
|
|
if err != nil || len(lineup) != 6 || lineup[0].IsBot || lineup[1].IsBot || !lineup[2].IsBot || lineup[2].Team != 0 {
|
|
t.Fatalf("casual lineup = %+v err=%v", lineup, err)
|
|
}
|
|
if _, err := BuildCasualLineup([]ConnectParticipant{{PlayerID: "p1", Team: 0}, {PlayerID: "p2", Team: 0}}); err == nil {
|
|
t.Fatal("lineup without a human on team 1 was accepted")
|
|
}
|
|
}
|
|
|
|
func TestCasualBackfillIsKickoffOnlyAndUnrated(t *testing.T) {
|
|
slot := CasualSlot{Slot: 2, Team: 0, PlayerID: "bot-slot-2", IsBot: true}
|
|
if !CanCasualBackfill(CasualKickoff, slot) || CanCasualBackfill(CasualLive, slot) || CasualBackfillPenalty() != 0 {
|
|
t.Fatal("casual backfill policy is incorrect")
|
|
}
|
|
if CanCasualBackfill(CasualKickoff, CasualSlot{Slot: 2, Team: 0, PlayerID: "human", IsBot: false}) {
|
|
t.Fatal("human slot was treated as backfillable")
|
|
}
|
|
}
|