mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-10 16:04:04 +00:00
24 lines
1.1 KiB
Go
24 lines
1.1 KiB
Go
package domain
|
|
|
|
import "testing"
|
|
|
|
func TestCasualLineupUsesBotsOnlyForMissingSlotsAndRequiresBothTeams(t *testing.T) {
|
|
lineup, err := BuildCasualLineup([]ConnectParticipant{{PlayerID: "p2", Team: 1, Slot: 3}, {PlayerID: "p1", Team: 0, Slot: 0}})
|
|
if err != nil || len(lineup) != 6 || lineup[0].IsBot || lineup[3].IsBot || !lineup[2].IsBot || lineup[2].Team != 0 || !lineup[5].IsBot || lineup[5].Team != 1 {
|
|
t.Fatalf("casual lineup = %+v err=%v", lineup, err)
|
|
}
|
|
if _, err := BuildCasualLineup([]ConnectParticipant{{PlayerID: "p1", Team: 0, Slot: 0}, {PlayerID: "p2", Team: 0, Slot: 1}}); 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")
|
|
}
|
|
}
|