add local MXL video adapter

This commit is contained in:
Dmitry Sergeev
2026-08-27 09:27:14 +03:00
parent 4f6ee895e7
commit 87b012db80
4 changed files with 168 additions and 1 deletions
+75
View File
@@ -0,0 +1,75 @@
package mxladapter
import (
"context"
"errors"
"testing"
"mxl-player/internal/playback"
"mxl-player/internal/source"
)
func TestVideoFactoryOpenVideoCanceled(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
cancel()
reader, err := (VideoFactory{}).OpenVideo(ctx, playback.FeedConfig{})
if reader != nil {
t.Fatal("OpenVideo() reader is not nil after cancellation")
}
if !errors.Is(err, context.Canceled) {
t.Fatalf("OpenVideo() error = %v, want context.Canceled", err)
}
}
func TestVideoFactoryOpenVideoRejectsInvalidConfig(t *testing.T) {
tests := []struct {
name string
config playback.FeedConfig
}{
{
name: "feed is not configured",
config: playback.FeedConfig{},
},
{
name: "active feed has no UUID",
config: playback.FeedConfig{
Domain: "/dev/shm/mxl",
Active: true,
},
},
{
name: "configured feed has no domain",
config: playback.FeedConfig{
UUID: "video-uuid",
Active: true,
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
reader, err := (VideoFactory{}).OpenVideo(
context.Background(),
tt.config,
)
if reader != nil {
t.Fatal("OpenVideo() reader is not nil for invalid config")
}
if err == nil {
t.Fatal("OpenVideo() error is nil for invalid config")
}
if got := source.KindOf(err); got != source.ErrorKindInvalidConfig {
t.Fatalf(
"source.KindOf(OpenVideo()) = %v, want %v",
got,
source.ErrorKindInvalidConfig,
)
}
if ShouldRetry(err) {
t.Fatal("ShouldRetry(OpenVideo()) = true for invalid config")
}
})
}
}