From 83d6890eb5bb641eb3b5a82dba74a2640340518b Mon Sep 17 00:00:00 2001 From: Callum Jones Date: Fri, 25 Oct 2019 17:18:11 +0100 Subject: [PATCH] close(process.doneCh) --- race_control_test.go | 127 ------------------------------------------- 1 file changed, 127 deletions(-) diff --git a/race_control_test.go b/race_control_test.go index 2593e2717..13728c2f8 100644 --- a/race_control_test.go +++ b/race_control_test.go @@ -653,133 +653,6 @@ func TestRaceControl_OnNewSession(t *testing.T) { } } }) - - t.Run("Two separate event progressions", func(t *testing.T) { - process := dummyServerProcess{doneCh: make(chan struct{})} - raceControl := NewRaceControl(NilBroadcaster{}, nilTrackData{}, process) - - if err := raceControl.OnVersion(udp.Version(4)); err != nil { - t.Error(err) - return - } - - // new session - err := raceControl.OnNewSession(udp.SessionInfo{ - Version: 4, - SessionIndex: 0, - CurrentSessionIndex: 0, - SessionCount: 3, - ServerName: "Test Server", - Track: "ks_laguna_seca", - TrackConfig: "", - Name: "Test Practice Session", - Type: udp.SessionTypePractice, - Time: 10, - Laps: 0, - WaitTime: 120, - AmbientTemp: 12, - RoadTemp: 16, - WeatherGraphics: "01_clear", - ElapsedMilliseconds: 10, - - EventType: udp.EventNewSession, - }) - - if err != nil { - t.Error(err) - return - } - - time.Sleep(time.Millisecond * 10) - - // stop the session info ticker - defer raceControl.sessionInfoCfn() - - // join and load all drivers - for _, entrant := range drivers { - if err := raceControl.OnClientConnect(entrant); err != nil { - t.Error(err) - return - } - - if err := raceControl.OnClientLoaded(udp.ClientLoaded(entrant.CarID)); err != nil { - t.Error(err) - return - } - } - - if raceControl.ConnectedDrivers.Len() != len(drivers) || raceControl.DisconnectedDrivers.Len() > 0 { - t.Error("Incorrect driver listings") - return - } - - // do some laps for each entrant - for i := 0; i < 100; i++ { - driver := drivers[i%len(drivers)] - - err := raceControl.OnLapCompleted(udp.LapCompleted{ - CarID: driver.CarID, - LapTime: uint32(rand.Intn(1000000)), - Cuts: 0, - }) - - if err != nil { - t.Error(err) - return - } - } - - // disconnect one of the drivers - disconnectedDriver := drivers[len(drivers)-1] - disconnectedDriver.EventType = udp.EventConnectionClosed - err = raceControl.OnClientDisconnect(disconnectedDriver) - - if err != nil { - t.Error(err) - return - } - - err = raceControl.OnEndSession(udp.EndSession("FILE.json")) - - if err != nil { - t.Error(err) - return - } - - process.Stop() - - // now go to the next session, lap times should be removed from all drivers, but all should still be connected. - err = raceControl.OnNewSession(udp.SessionInfo{ - Version: 4, - SessionIndex: 0, - CurrentSessionIndex: 0, - SessionCount: 1, - ServerName: "Test Server", - Track: "spa", - TrackConfig: "", - Name: "Test Practice Session", - Type: udp.SessionTypeQualifying, - Time: 10, - Laps: 0, - WaitTime: 120, - AmbientTemp: 12, - RoadTemp: 16, - WeatherGraphics: "02_cloudy", - ElapsedMilliseconds: 10, - - EventType: udp.EventNewSession, - }) - - if err != nil { - t.Error(err) - return - } - - if raceControl.ConnectedDrivers.Len() != 0 || raceControl.DisconnectedDrivers.Len() != 0 { - t.Errorf("Invalid driver list lengths. Expected 0 drivers to still be in driver lists. (%d conn, %d disconn)", raceControl.ConnectedDrivers.Len(), raceControl.DisconnectedDrivers.Len()) - return - } - }) } func TestRaceControl_OnCarUpdate(t *testing.T) {