@@ -190,34 +190,56 @@ func TestCommitCards(t *testing.T) {
190
190
web := setupTestWeb (t )
191
191
192
192
// Check that a yellow card sticks with a team.
193
- team := & model.Team {Id : 5 }
194
- web .arena .Database .CreateTeam (team )
193
+ team1 := & model.Team {Id : 3 }
194
+ team2 := & model.Team {Id : 5 }
195
+ web .arena .Database .CreateTeam (team1 )
196
+ web .arena .Database .CreateTeam (team2 )
195
197
match := & model.Match {Id : 0 , Type : model .Qualification , Red1 : 1 , Red2 : 2 , Red3 : 3 , Blue1 : 4 , Blue2 : 5 , Blue3 : 6 }
196
198
assert .Nil (t , web .arena .Database .CreateMatch (match ))
197
199
matchResult := model .NewMatchResult ()
198
200
matchResult .MatchId = match .Id
201
+ matchResult .RedCards = map [string ]string {"3" : "yellow" }
199
202
matchResult .BlueCards = map [string ]string {"5" : "yellow" }
200
203
err := web .commitMatchScore (match , matchResult , true )
201
204
assert .Nil (t , err )
202
- team , _ = web .arena .Database .GetTeamById (5 )
203
- assert .True (t , team .YellowCard )
205
+ team1 , _ = web .arena .Database .GetTeamById (3 )
206
+ assert .True (t , team1 .YellowCard )
207
+ team2 , _ = web .arena .Database .GetTeamById (5 )
208
+ assert .True (t , team2 .YellowCard )
204
209
205
210
// Check that editing a match result removes a yellow card from a team.
206
211
matchResult = model .NewMatchResult ()
207
212
matchResult .MatchId = match .Id
208
213
err = web .commitMatchScore (match , matchResult , true )
209
214
assert .Nil (t , err )
210
- team , _ = web .arena .Database .GetTeamById (5 )
211
- assert .False (t , team .YellowCard )
215
+ team1 , _ = web .arena .Database .GetTeamById (3 )
216
+ assert .False (t , team1 .YellowCard )
217
+ team2 , _ = web .arena .Database .GetTeamById (5 )
218
+ assert .False (t , team2 .YellowCard )
212
219
213
220
// Check that a red card causes a yellow card to stick with a team.
214
221
matchResult = model .NewMatchResult ()
215
222
matchResult .MatchId = match .Id
223
+ matchResult .RedCards = map [string ]string {"3" : "red" }
216
224
matchResult .BlueCards = map [string ]string {"5" : "red" }
217
225
err = web .commitMatchScore (match , matchResult , true )
218
226
assert .Nil (t , err )
219
- team , _ = web .arena .Database .GetTeamById (5 )
220
- assert .True (t , team .YellowCard )
227
+ team1 , _ = web .arena .Database .GetTeamById (3 )
228
+ assert .True (t , team1 .YellowCard )
229
+ team2 , _ = web .arena .Database .GetTeamById (5 )
230
+ assert .True (t , team2 .YellowCard )
231
+
232
+ // Check that a DQ does not cause a yellow card to stick with a team.
233
+ matchResult = model .NewMatchResult ()
234
+ matchResult .MatchId = match .Id
235
+ matchResult .RedCards = map [string ]string {"3" : "dq" }
236
+ matchResult .BlueCards = map [string ]string {"5" : "dq" }
237
+ err = web .commitMatchScore (match , matchResult , true )
238
+ assert .Nil (t , err )
239
+ team1 , _ = web .arena .Database .GetTeamById (3 )
240
+ assert .False (t , team1 .YellowCard )
241
+ team2 , _ = web .arena .Database .GetTeamById (5 )
242
+ assert .False (t , team2 .YellowCard )
221
243
222
244
// Check that a red card in playoffs zeroes out the score.
223
245
tournament .CreateTestAlliances (web .arena .Database , 2 )
@@ -235,6 +257,13 @@ func TestCommitCards(t *testing.T) {
235
257
assert .Nil (t , web .commitMatchScore (match , matchResult , true ))
236
258
assert .Equal (t , 0 , matchResult .RedScoreSummary ().Score )
237
259
assert .NotEqual (t , 0 , matchResult .BlueScoreSummary ().Score )
260
+
261
+ // Check that a DQ in playoffs zeroes out the score.
262
+ matchResult .RedCards = map [string ]string {}
263
+ matchResult .BlueCards = map [string ]string {"5" : "dq" }
264
+ assert .Nil (t , web .commitMatchScore (match , matchResult , true ))
265
+ assert .NotEqual (t , 0 , matchResult .RedScoreSummary ().Score )
266
+ assert .Equal (t , 0 , matchResult .BlueScoreSummary ().Score )
238
267
}
239
268
240
269
func TestMatchPlayWebsocketCommands (t * testing.T ) {
0 commit comments