package settings import ( "testing" "av1dae/pkg/types" ) func valid() Settings { return Settings{ DVD: Profile{30, 2}, Bluray: Profile{29, 3}, WebDL: Profile{30, 3}, TVRip: Profile{32, 2}, LP: 0, LogRetentionDays: 7, } } func TestValidate(t *testing.T) { if err := valid().Validate(); err != nil { t.Fatalf("valid settings rejected: %v", err) } bad := func(mut func(*Settings)) Settings { s := valid(); mut(&s); return s } cases := map[string]Settings{ "crf too high": bad(func(s *Settings) { s.DVD.CRF = 64 }), "crf negative": bad(func(s *Settings) { s.Bluray.CRF = -1 }), "preset too high": bad(func(s *Settings) { s.WebDL.Preset = 14 }), "lp negative": bad(func(s *Settings) { s.LP = -1 }), "retention zero": bad(func(s *Settings) { s.LogRetentionDays = 0 }), } for name, s := range cases { if err := s.Validate(); err == nil { t.Errorf("%s: expected validation error, got nil", name) } } } func TestProfileFor(t *testing.T) { s := valid() if s.ProfileFor(types.MediaTypeBluRay) != s.Bluray { t.Error("bluray profile mismatch") } if s.ProfileFor(types.MediaTypeWebDL) != s.WebDL { t.Error("webdl profile mismatch") } if s.ProfileFor(types.MediaType("anything-else")) != s.DVD { t.Error("unknown media type should fall back to DVD") } }