Files
hockey_new/agent/scanner_test.go
2026-08-19 15:08:39 +03:00

18 lines
935 B
Go

package main
import (
"net/http"
"net/http/httptest"
"testing"
)
func TestScanVmixInventory(t *testing.T) {
xml := `<vmix><version>29.0.0.48</version><inputs><input key="abc" number="12" type="GT" title="Scorebug"><text index="0" name="HomeTeam.Text">SKA</text><image index="0" name="HomeLogo.Source">c:\\logo.png</image></input></inputs></vmix>`
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]) }
}