Refactoring #3

Merged
itten merged 87 commits from refactoring into main 2026-09-01 23:52:36 +03:00
2 changed files with 48 additions and 0 deletions
Showing only changes of commit 418d0fc102 - Show all commits
+21
View File
@@ -1,5 +1,15 @@
package playback
import "time"
type Unit uint8
const (
UnitVideo Unit = iota
UnitAudio
UnitSync
)
type State uint8
const (
@@ -10,3 +20,14 @@ const (
StateFailed
StateStopping
)
type Status struct {
Unit Unit
State State
Attempt int
FailedAttempts int
RetryIn time.Duration
Err error
}
type StatusObserver func(Status)
+27
View File
@@ -0,0 +1,27 @@
package playback
import (
"errors"
"testing"
"time"
)
func TestStatusPreservesValues(t *testing.T) {
wantErr := errors.New("producer missing")
status := Status{
Unit: UnitVideo,
State: StateReconnecting,
Attempt: 2,
FailedAttempts: 1,
RetryIn: time.Second,
Err: wantErr,
}
if status.Unit != UnitVideo {
t.Errorf("Unit = %v, want %v", status.Unit, UnitVideo)
}
// Check the remaining fields similarly.
if !errors.Is(status.Err, wantErr) {
t.Errorf("Err = %v, want %v", status.Err, wantErr)
}
}