- Preview player can select FHD/HD/SD (or ABR master) from publish links - Embed dashboard screenshots in README; Linux streamd+agent setup guide - C4 Widevine wrap license mode + require --wvd; prefer Widevine PSSH - Channel 4 and My5 modules; streamd auth, variants, schedules, HLS gate
57 lines
1.5 KiB
Go
57 lines
1.5 KiB
Go
package db
|
|
|
|
import (
|
|
"path/filepath"
|
|
"testing"
|
|
)
|
|
|
|
func TestApplyCreateDefaultsFillsUnsetFields(t *testing.T) {
|
|
s, err := Open(filepath.Join(t.TempDir(), "d"))
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
t.Cleanup(func() { _ = s.Close() })
|
|
|
|
if err := s.SetSettings(map[string]string{
|
|
SettingOnDemand: "true",
|
|
SettingIdleTimeoutS: "120",
|
|
SettingDefaultOutputs: `[{"id":"hls","label":"HLS","format":"hls","enabled":true}]`,
|
|
}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
in := CreateStream{Name: "news"}
|
|
s.ApplyCreateDefaults(&in)
|
|
if in.OnDemand == nil || !*in.OnDemand {
|
|
t.Fatalf("expected on_demand=true from settings, got %+v", in.OnDemand)
|
|
}
|
|
if in.IdleTimeoutS == nil || *in.IdleTimeoutS != 120 {
|
|
t.Fatalf("expected idle_timeout_s=120, got %+v", in.IdleTimeoutS)
|
|
}
|
|
if in.OutputsJSON == "" {
|
|
t.Fatal("expected default_outputs JSON to be copied")
|
|
}
|
|
}
|
|
|
|
func TestApplyCreateDefaultsDoesNotOverrideExplicit(t *testing.T) {
|
|
s, err := Open(filepath.Join(t.TempDir(), "d"))
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
t.Cleanup(func() { _ = s.Close() })
|
|
|
|
_ = s.SetSettings(map[string]string{
|
|
SettingOnDemand: "true",
|
|
SettingIdleTimeoutS: "120",
|
|
})
|
|
off := false
|
|
idle := 600
|
|
in := CreateStream{Name: "news", OnDemand: &off, IdleTimeoutS: &idle}
|
|
s.ApplyCreateDefaults(&in)
|
|
if in.OnDemand == nil || *in.OnDemand {
|
|
t.Fatal("explicit on_demand=false must win over settings")
|
|
}
|
|
if in.IdleTimeoutS == nil || *in.IdleTimeoutS != 600 {
|
|
t.Fatal("explicit idle_timeout_s must win over settings")
|
|
}
|
|
}
|