test(go): assert ping echo in JSON output; comment ping fallback
TestRunPingJSON now verifies the fake gateway's echoed text appears in the serialised reply body, catching any future wiring regression that maps PingRaw to the wrong proto field. runPing gains a one-line comment explaining why DiagnosticMessage carries the echo, why the kind-string fallback exists, and why writeCommandOutput is not reused on the plain-text path.
This commit is contained in:
@@ -255,6 +255,13 @@ func TestRunPingJSON(t *testing.T) {
|
||||
if out.Command != "ping" {
|
||||
t.Fatalf("command = %q, want %q", out.Command, "ping")
|
||||
}
|
||||
// The fake gateway echoes "pong:<message>" in diagnostic_message; verify the
|
||||
// echo appears in the serialised reply so a future regression that wired
|
||||
// PingRaw to the wrong proto field would be caught here.
|
||||
replyStr := string(out.Reply)
|
||||
if !strings.Contains(replyStr, "pong:hello") {
|
||||
t.Fatalf("ping JSON reply missing echoed message %q; reply = %s", "pong:hello", replyStr)
|
||||
}
|
||||
}
|
||||
|
||||
// TestRunPingRequiresSessionID verifies the ping subcommand rejects missing session-id.
|
||||
|
||||
Reference in New Issue
Block a user