package main import ( "testing" "github.com/kami/maven/internal/config" "github.com/kami/maven/internal/stt" ) // A box with no workstation.stt block transcribes exactly as it did before the // seam existed: the floor is handed back untouched, and nothing probes. func TestSttSeamWithNoBlockIsTheFloor(t *testing.T) { floor := stt.NewStub() got, pair := sttSeam(&config.Config{}, floor) if pair != nil { t.Fatal("no block must build no pair") } if got != stt.Transcriber(floor) { t.Fatal("no block must hand back the floor itself") } } func TestSttSeamPrefersTheWorkstation(t *testing.T) { cfg := &config.Config{Workstation: &config.WorkstationConfig{ URL: "http://127.0.0.1:1", Stt: &config.WorkstationSttConfig{ URL: "http://127.0.0.1:2/transcribe", Health: "http://127.0.0.1:2/health", }, }} got, pair := sttSeam(cfg, stt.NewStub()) if pair == nil { t.Fatal("a configured block must build a pair") } defer pair.Stop() if got != stt.Transcriber(pair) { t.Fatal("the pair is what callers must transcribe through") } // Nothing answers on port 2, so the seam is the floor until it does. if pair.Available() { t.Fatal("an unreachable workstation must not be available") } }