Skip to content

Commit 2fd457e

Browse files
committed
[bugfix] Fix unit tests
1 parent f084f65 commit 2fd457e

File tree

5 files changed

+25
-0
lines changed

5 files changed

+25
-0
lines changed

internal/app/controller/engine.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -690,6 +690,9 @@ func (e *Engine) updateNextCommandForStage() {
690690
case StageSecondHalfPre, StageOvertimeSecondHalfPre:
691691
e.State.NextCommand = CommandKickoff
692692
e.State.NextCommandFor = e.GcState.FirstKickoffTeam.Opposite()
693+
default:
694+
e.State.NextCommand = ""
695+
e.State.NextCommandFor = ""
693696
}
694697
}
695698

internal/app/controller/engine_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ func processTransitionFile(t *testing.T, fileName string) {
112112
t.Fatal(err)
113113
}
114114
stateTransitions.InitialState.applyTo(e.GcState)
115+
e.updateNextCommandForStage()
116+
115117
// initialize the expected state with the current engine state
116118
expectedState := e.GcState.DeepCopy()
117119

internal/app/controller/testdata/engine_test_command_kickoff.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ transitions:
88
type: stop
99
expectedStateDiff:
1010
command: stop
11+
nextCommand: kickoff
12+
nextCommandFor: Yellow
1113
- event:
1214
command:
1315
type: kickoff
@@ -16,6 +18,7 @@ transitions:
1618
command: kickoff
1719
commandFor: Yellow
1820
nextCommand: normalStart
21+
nextCommandFor: ""
1922
- event:
2023
command:
2124
type: normalStart

internal/app/controller/testdata/engine_test_gameevent_kickoff.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ transitions:
88
type: stop
99
expectedStateDiff:
1010
command: stop
11+
nextCommand: kickoff
12+
nextCommandFor: Yellow
1113
- tick: 1s # make sure that the stage time is not proceeded
1214
- event:
1315
command:
@@ -17,6 +19,7 @@ transitions:
1719
command: kickoff
1820
commandFor: Blue
1921
nextCommand: normalStart
22+
nextCommandFor: ""
2023
- event:
2124
gameEvent:
2225
type: prepared

internal/app/controller/testdata/engine_test_stage_full_forward.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ transitions:
1010
stage: First Half
1111
stageTimeLeft: 5m
1212
matchTimeStart: "2010-01-01T00:00:00Z"
13+
nextCommand: ""
14+
nextCommandFor: ""
1315
- event:
1416
stage:
1517
stageOperation: next
@@ -22,12 +24,16 @@ transitions:
2224
expectedStateDiff:
2325
stage: Pre-Second Half
2426
stageTimeLeft: 0
27+
nextCommand: kickoff
28+
nextCommandFor: Blue
2529
- event:
2630
stage:
2731
stageOperation: next
2832
expectedStateDiff:
2933
stage: Second Half
3034
stageTimeLeft: 5m
35+
nextCommand: ""
36+
nextCommandFor: ""
3137
- event:
3238
stage:
3339
stageOperation: next
@@ -40,6 +46,8 @@ transitions:
4046
expectedStateDiff:
4147
stage: Pre-Overtime First Half
4248
stageTimeLeft: 0
49+
nextCommand: kickoff
50+
nextCommandFor: Yellow
4351
teamState:
4452
Blue:
4553
timeoutsLeft: 2
@@ -51,6 +59,8 @@ transitions:
5159
expectedStateDiff:
5260
stage: Overtime First Half
5361
stageTimeLeft: 2m30s
62+
nextCommand: ""
63+
nextCommandFor: ""
5464
- event:
5565
stage:
5666
stageOperation: next
@@ -63,12 +73,16 @@ transitions:
6373
expectedStateDiff:
6474
stage: Pre-Overtime Second Half
6575
stageTimeLeft: 0
76+
nextCommand: kickoff
77+
nextCommandFor: Blue
6678
- event:
6779
stage:
6880
stageOperation: next
6981
expectedStateDiff:
7082
stage: Overtime Second Half
7183
stageTimeLeft: 2m30s
84+
nextCommand: ""
85+
nextCommandFor: ""
7286
- event:
7387
stage:
7488
stageOperation: next

0 commit comments

Comments
 (0)