mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-11 17:53:44 +00:00
40 lines
1.5 KiB
Go
40 lines
1.5 KiB
Go
package domain
|
|
|
|
import "testing"
|
|
|
|
func rankedParticipants() []RankedParticipant {
|
|
result := make([]RankedParticipant, 6)
|
|
for i := range result {
|
|
result[i] = RankedParticipant{PlayerID: string(rune('a' + i)), SteamID: string(rune('A' + i))}
|
|
}
|
|
return result
|
|
}
|
|
|
|
func TestRankedAdmissionRequiresSixUniqueVerifiedSoloHumansAndEligibleArena(t *testing.T) {
|
|
if err := ValidateRankedAdmission(rankedParticipants(), RankedArena{RandomEnabled: true}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
cases := []struct {
|
|
name string
|
|
edit func([]RankedParticipant, *RankedArena)
|
|
}{
|
|
{"five players", func(p []RankedParticipant, _ *RankedArena) { p[5].PlayerID = "" }},
|
|
{"party", func(p []RankedParticipant, _ *RankedArena) { p[0].PartyID = "party-1" }},
|
|
{"bot", func(p []RankedParticipant, _ *RankedArena) { p[0].IsBot = true }},
|
|
{"backfill", func(p []RankedParticipant, _ *RankedArena) { p[0].IsBackfill = true }},
|
|
{"duplicate identity", func(p []RankedParticipant, _ *RankedArena) { p[1].SteamID = p[0].SteamID }},
|
|
{"random disabled", func(_ []RankedParticipant, a *RankedArena) { a.RandomEnabled = false }},
|
|
{"elevated arena", func(_ []RankedParticipant, a *RankedArena) { a.ElevatedGoals = true }},
|
|
}
|
|
for _, test := range cases {
|
|
t.Run(test.name, func(t *testing.T) {
|
|
participants := rankedParticipants()
|
|
arena := RankedArena{RandomEnabled: true}
|
|
test.edit(participants, &arena)
|
|
if err := ValidateRankedAdmission(participants, arena); err == nil {
|
|
t.Fatal("invalid ranked admission accepted")
|
|
}
|
|
})
|
|
}
|
|
}
|