package main
import (
"net/http"
"net/http/httptest"
"testing"
)
func TestScanVmixInventory(t *testing.T) {
xml := `29.0.0.48SKAc:\\logo.png`
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/xml")
_, _ = w.Write([]byte(xml))
}))
defer srv.Close()
status, inv := scanVmix(srv.URL)
if !status.Connected || status.Version != "29.0.0.48" {
t.Fatalf("bad status: %+v", status)
}
if inv.InputCount != 1 || inv.FieldCount != 2 || len(inv.Fingerprint) != 64 {
t.Fatalf("bad inventory: %+v", inv)
}
if inv.Inputs[0].Title != "Scorebug" || len(inv.Inputs[0].Fields) != 2 {
t.Fatalf("bad input: %+v", inv.Inputs[0])
}
}
func TestScanVmixOverlayTallyResolvesInputIdentity(t *testing.T) {
xml := `` +
`GEO` +
`SCORE` +
`` +
`5` +
`` +
`` +
`16` +
``
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/xml")
_, _ = w.Write([]byte(xml))
}))
defer srv.Close()
overlays, connected := scanVmixOverlayTally(srv.URL)
if !connected {
t.Fatal("expected vMix tally connection")
}
if got := overlays["4"]; got.InputNumber != "16" || got.InputKey != "geo-guid" || got.InputTitle != "GEO" {
t.Fatalf("bad overlay 4 tally: %+v", got)
}
if got := overlays["1"]; got.InputNumber != "5" || got.InputKey != "score-guid" {
t.Fatalf("bad overlay 1 tally: %+v", got)
}
if _, ok := overlays["2"]; ok {
t.Fatalf("empty overlay 2 must not be active: %+v", overlays["2"])
}
}