package protocol import ( "encoding/json" "strings" "testing" ) // TestSystemStatusOpenCodeField pins the wire shape the server and every client // agree on: the OpenCode attachment report is a nested "opencode" object and it // carries no credential field. func TestSystemStatusOpenCodeField(t *testing.T) { encoded, err := json.Marshal(SystemStatus{OpenCode: ServiceStatus{Health: "endpoint", URL: "http://127.0.0.1:49374"}}) if err != nil { t.Fatal(err) } text := string(encoded) if !strings.Contains(text, `"opencode":{"health":"endpoint"`) { t.Fatalf("opencode status not encoded as expected: %s", text) } var decoded SystemStatus if err := json.Unmarshal(encoded, &decoded); err != nil { t.Fatal(err) } if decoded.OpenCode.Health != "endpoint" || decoded.OpenCode.URL != "http://127.0.0.1:49374" { t.Fatalf("round trip lost the opencode status: %+v", decoded.OpenCode) } }