package parking import ( "testing" "time" ) func TestRecentCameraStreamFrameMarksCameraOnline(t *testing.T) { deviceCode := "camera-stream-status-test" cameraLastFrameAt.Delete(deviceCode) t.Cleanup(func() { cameraLastFrameAt.Delete(deviceCode) }) if hasRecentCameraStreamFrame(deviceCode) { t.Fatal("camera without video output must be offline") } markCameraStreamFrame(deviceCode) if !hasRecentCameraStreamFrame(deviceCode) { t.Fatal("camera with recent video output must be online") } cameraLastFrameAt.Store(deviceCode, time.Now().Add(-cameraStreamOnlineTTL-time.Millisecond)) if hasRecentCameraStreamFrame(deviceCode) { t.Fatal("camera with expired video output must be offline") } }