architecture cleanup
This commit is contained in:
@@ -68,9 +68,11 @@ func TestPlaylistControllerStartsOneTimerForMatchingReadiness(t *testing.T) {
|
||||
return snapshot.Revision == 1
|
||||
})
|
||||
|
||||
readiness <- PlaylistReadiness{Revision: 0}
|
||||
readiness <- PlaylistEvent{Revision: 0}
|
||||
assertNoPlaylistTimer(t, timers)
|
||||
readiness <- PlaylistReadiness{Revision: 1}
|
||||
readiness <- PlaylistEvent{Revision: 1, Kind: PlaylistEventKind(99)}
|
||||
assertNoPlaylistTimer(t, timers)
|
||||
readiness <- PlaylistEvent{Revision: 1}
|
||||
timer := receiveFakePlaylistTimer(t, timers)
|
||||
|
||||
snapshot := waitForPlaylistSnapshot(t, controller, func(snapshot PlaylistSnapshot) bool {
|
||||
@@ -79,7 +81,7 @@ func TestPlaylistControllerStartsOneTimerForMatchingReadiness(t *testing.T) {
|
||||
if snapshot.Timing.Deadline != now.Add(10*time.Second) {
|
||||
t.Fatalf("deadline = %v, want %v", snapshot.Timing.Deadline, now.Add(10*time.Second))
|
||||
}
|
||||
readiness <- PlaylistReadiness{Revision: 1}
|
||||
readiness <- PlaylistEvent{Revision: 1}
|
||||
assertNoPlaylistTimer(t, timers)
|
||||
if timer.isStopped() {
|
||||
t.Fatal("timer stopped after duplicate readiness")
|
||||
@@ -101,7 +103,7 @@ func TestPlaylistControllerTimerExpiryAdvances(t *testing.T) {
|
||||
|
||||
commands <- PlaylistCommand{Kind: PlaylistNext}
|
||||
_ = receivePlaylistSession(t, sessions)
|
||||
readiness <- PlaylistReadiness{Revision: 1}
|
||||
readiness <- PlaylistEvent{Revision: 1}
|
||||
timer := receiveFakePlaylistTimer(t, timers)
|
||||
timer.fire(now.Add(10 * time.Second))
|
||||
|
||||
@@ -132,7 +134,7 @@ func TestPlaylistControllerLoopingTimerExpiryWraps(t *testing.T) {
|
||||
|
||||
commands <- PlaylistCommand{Kind: PlaylistSelect, Index: 1}
|
||||
_ = receivePlaylistSession(t, sessions)
|
||||
readiness <- PlaylistReadiness{Revision: 1}
|
||||
readiness <- PlaylistEvent{Revision: 1}
|
||||
timer := receiveFakePlaylistTimer(t, timers)
|
||||
waitForPlaylistSnapshot(t, controller, func(snapshot PlaylistSnapshot) bool {
|
||||
return snapshot.Timing.Started
|
||||
@@ -160,7 +162,7 @@ func TestPlaylistControllerFinalExpiryStopsWithoutCommand(t *testing.T) {
|
||||
|
||||
commands <- PlaylistCommand{Kind: PlaylistSelect, Index: 1}
|
||||
_ = receivePlaylistSession(t, sessions)
|
||||
readiness <- PlaylistReadiness{Revision: 1}
|
||||
readiness <- PlaylistEvent{Revision: 1}
|
||||
timer := receiveFakePlaylistTimer(t, timers)
|
||||
waitForPlaylistSnapshot(t, controller, func(snapshot PlaylistSnapshot) bool {
|
||||
return snapshot.Timing.Started
|
||||
@@ -192,7 +194,7 @@ func TestPlaylistControllerManualSelectionStopsOldTimer(t *testing.T) {
|
||||
|
||||
commands <- PlaylistCommand{Kind: PlaylistNext}
|
||||
_ = receivePlaylistSession(t, sessions)
|
||||
readiness <- PlaylistReadiness{Revision: 1}
|
||||
readiness <- PlaylistEvent{Revision: 1}
|
||||
oldTimer := receiveFakePlaylistTimer(t, timers)
|
||||
|
||||
commands <- PlaylistCommand{Kind: PlaylistSelect, Index: 1}
|
||||
@@ -229,7 +231,7 @@ func TestPlaylistControllerZeroDurationDoesNotCreateTimer(t *testing.T) {
|
||||
|
||||
commands <- PlaylistCommand{Kind: PlaylistNext}
|
||||
_ = receivePlaylistSession(t, sessions)
|
||||
readiness <- PlaylistReadiness{Revision: 1}
|
||||
readiness <- PlaylistEvent{Revision: 1}
|
||||
assertNoPlaylistTimer(t, timers)
|
||||
|
||||
close(commands)
|
||||
@@ -244,7 +246,7 @@ func TestPlaylistControllerCancellationStopsTimer(t *testing.T) {
|
||||
|
||||
commands <- PlaylistCommand{Kind: PlaylistNext}
|
||||
_ = receivePlaylistSession(t, sessions)
|
||||
readiness <- PlaylistReadiness{Revision: 1}
|
||||
readiness <- PlaylistEvent{Revision: 1}
|
||||
timer := receiveFakePlaylistTimer(t, timers)
|
||||
cancel()
|
||||
if err := waitForPlaylistResult(t, result); !errors.Is(err, context.Canceled) {
|
||||
@@ -262,7 +264,7 @@ func TestPlaylistControllerPauseAndResumeTimer(t *testing.T) {
|
||||
|
||||
commands <- PlaylistCommand{Kind: PlaylistNext}
|
||||
_ = receivePlaylistSession(t, sessions)
|
||||
readiness <- PlaylistReadiness{Revision: 1}
|
||||
readiness <- PlaylistEvent{Revision: 1}
|
||||
oldTimer := receiveFakePlaylistTimer(t, timers)
|
||||
waitForPlaylistSnapshot(t, controller, func(snapshot PlaylistSnapshot) bool {
|
||||
return snapshot.Timing.Started
|
||||
@@ -344,7 +346,7 @@ func TestPlaylistControllerRecordsQueuedReadinessWhilePaused(t *testing.T) {
|
||||
return snapshot.Timing.Paused
|
||||
})
|
||||
|
||||
readiness <- PlaylistReadiness{Revision: 1}
|
||||
readiness <- PlaylistEvent{Revision: 1}
|
||||
waitForPlaylistSnapshot(t, controller, func(snapshot PlaylistSnapshot) bool {
|
||||
return snapshot.Timing.Paused && snapshot.Timing.Ready
|
||||
})
|
||||
@@ -368,7 +370,7 @@ func startTimedPlaylistController(
|
||||
) (
|
||||
*PlaylistController,
|
||||
chan PlaylistCommand,
|
||||
chan PlaylistReadiness,
|
||||
chan PlaylistEvent,
|
||||
chan SessionCommand,
|
||||
chan *fakePlaylistTimer,
|
||||
time.Time,
|
||||
@@ -390,7 +392,7 @@ func startTimedPlaylistController(
|
||||
return timer
|
||||
}
|
||||
commands := make(chan PlaylistCommand, 16)
|
||||
readiness := make(chan PlaylistReadiness, 16)
|
||||
readiness := make(chan PlaylistEvent, 16)
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
result := make(chan error, 1)
|
||||
go func() { result <- controller.Run(ctx, commands, readiness) }()
|
||||
|
||||
Reference in New Issue
Block a user