142 lines
3.7 KiB
Go
142 lines
3.7 KiB
Go
package main
|
|
|
|
import "testing"
|
|
|
|
func TestAppArgsPlaybackConfig(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
args appArgs
|
|
wantVideoDomain string
|
|
wantAudioDomain string
|
|
wantVideoActive bool
|
|
wantAudioActive bool
|
|
wantSyncRequested bool
|
|
wantMaxAttempts int
|
|
}{
|
|
{
|
|
name: "shared domain applies to both feeds",
|
|
args: appArgs{
|
|
Domain: "/dev/shm/mxl",
|
|
VideoFlowId: "video-uuid",
|
|
AudioFlowId: "audio-uuid",
|
|
},
|
|
wantVideoDomain: "/dev/shm/mxl",
|
|
wantAudioDomain: "/dev/shm/mxl",
|
|
wantVideoActive: true,
|
|
wantAudioActive: true,
|
|
},
|
|
{
|
|
name: "video domain overrides shared domain",
|
|
args: appArgs{
|
|
Domain: "/dev/shm/default",
|
|
VideoDomain: "/dev/shm/video",
|
|
VideoFlowId: "video-uuid",
|
|
AudioFlowId: "audio-uuid",
|
|
},
|
|
wantVideoDomain: "/dev/shm/video",
|
|
wantAudioDomain: "/dev/shm/default",
|
|
wantVideoActive: true,
|
|
wantAudioActive: true,
|
|
},
|
|
{
|
|
name: "audio domain overrides shared domain",
|
|
args: appArgs{
|
|
Domain: "/dev/shm/default",
|
|
AudioDomain: "/dev/shm/audio",
|
|
VideoFlowId: "video-uuid",
|
|
AudioFlowId: "audio-uuid",
|
|
},
|
|
wantVideoDomain: "/dev/shm/default",
|
|
wantAudioDomain: "/dev/shm/audio",
|
|
wantVideoActive: true,
|
|
wantAudioActive: true,
|
|
},
|
|
{
|
|
name: "audio and video use different domain overrides",
|
|
args: appArgs{
|
|
Domain: "/dev/shm/default",
|
|
VideoDomain: "/dev/shm/video",
|
|
AudioDomain: "/dev/shm/audio",
|
|
VideoFlowId: "video-uuid",
|
|
AudioFlowId: "audio-uuid",
|
|
SyncRequested: true,
|
|
MaxAttempts: 5,
|
|
},
|
|
wantVideoDomain: "/dev/shm/video",
|
|
wantAudioDomain: "/dev/shm/audio",
|
|
wantVideoActive: true,
|
|
wantAudioActive: true,
|
|
wantSyncRequested: true,
|
|
wantMaxAttempts: 5,
|
|
},
|
|
{
|
|
name: "no UUIDs produce inactive slots",
|
|
args: appArgs{
|
|
Domain: "/dev/shm/mxl",
|
|
},
|
|
wantVideoDomain: "/dev/shm/mxl",
|
|
wantAudioDomain: "/dev/shm/mxl",
|
|
},
|
|
{
|
|
name: "video UUID activates only video",
|
|
args: appArgs{
|
|
Domain: "/dev/shm/mxl",
|
|
VideoFlowId: "video-uuid",
|
|
},
|
|
wantVideoDomain: "/dev/shm/mxl",
|
|
wantAudioDomain: "/dev/shm/mxl",
|
|
wantVideoActive: true,
|
|
},
|
|
{
|
|
name: "audio UUID activates only audio",
|
|
args: appArgs{
|
|
Domain: "/dev/shm/mxl",
|
|
AudioFlowId: "audio-uuid",
|
|
},
|
|
wantVideoDomain: "/dev/shm/mxl",
|
|
wantAudioDomain: "/dev/shm/mxl",
|
|
wantAudioActive: true,
|
|
},
|
|
{
|
|
name: "unlimited attempts and disabled sync are preserved",
|
|
args: appArgs{
|
|
Domain: "/dev/shm/mxl",
|
|
VideoFlowId: "video-uuid",
|
|
SyncRequested: false,
|
|
MaxAttempts: 0,
|
|
},
|
|
wantVideoDomain: "/dev/shm/mxl",
|
|
wantAudioDomain: "/dev/shm/mxl",
|
|
wantVideoActive: true,
|
|
},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
got := tt.args.playbackConfig()
|
|
|
|
if got.Video.Domain != tt.wantVideoDomain {
|
|
t.Errorf("video domain = %q, want %q", got.Video.Domain, tt.wantVideoDomain)
|
|
}
|
|
if got.Audio.Domain != tt.wantAudioDomain {
|
|
t.Errorf("audio domain = %q, want %q", got.Audio.Domain, tt.wantAudioDomain)
|
|
}
|
|
if got.Video.Active != tt.wantVideoActive {
|
|
t.Errorf("video active = %t, want %t", got.Video.Active, tt.wantVideoActive)
|
|
}
|
|
if got.Audio.Active != tt.wantAudioActive {
|
|
t.Errorf("audio active = %t, want %t", got.Audio.Active, tt.wantAudioActive)
|
|
}
|
|
if got.SyncRequested != tt.wantSyncRequested {
|
|
t.Errorf("sync requested = %t, want %t", got.SyncRequested, tt.wantSyncRequested)
|
|
}
|
|
if got.Retry.MaxAttempts != tt.wantMaxAttempts {
|
|
t.Errorf("max attempts = %d, want %d", got.Retry.MaxAttempts, tt.wantMaxAttempts)
|
|
}
|
|
if err := got.Validate(); err != nil {
|
|
t.Fatalf("playbackConfig().Validate() returned error: %v", err)
|
|
}
|
|
})
|
|
}
|
|
}
|