package api import ( "os" "path/filepath" "testing" "streamd/apps/streamd/internal/modstore" ) func TestChannelsFromStoreYAML(t *testing.T) { root := t.TempDir() store := modstore.New(root) modDir := filepath.Join(root, "rte") if err := os.MkdirAll(modDir, 0o755); err != nil { t.Fatal(err) } yaml := []byte(`package: air.RTE channels: rteone: label: RTE One rtetwo: label: RTE 2 `) if err := os.WriteFile(filepath.Join(modDir, "module.yaml"), yaml, 0o644); err != nil { t.Fatal(err) } chans := channelsFromStoreYAML(store, "rte") if len(chans) != 2 { t.Fatalf("got %d channels: %+v", len(chans), chans) } if chans[0].ID != "rteone" || chans[0].Label != "RTE One" { t.Fatalf("first channel: %+v", chans[0]) } if chans[1].ID != "rtetwo" { t.Fatalf("second channel: %+v", chans[1]) } } func TestChannelsFromStoreYAMLMissing(t *testing.T) { store := modstore.New(t.TempDir()) if chans := channelsFromStoreYAML(store, "nope"); chans != nil { t.Fatalf("expected nil, got %+v", chans) } }