MCPcopy Create free account
hub / github.com/asternic/wuzapi / TestNumericZeroRequestID

Function TestNumericZeroRequestID

stdio_test.go:628–650  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

626}
627
628func TestNumericZeroRequestID(t *testing.T) {
629 s := makeTestServer(t)
630
631 // Send request with numeric ID 0 (valid per JSON-RPC 2.0 spec)
632 request := newRequest(0, "health", nil).toJSON(t)
633 response := executeRequest(t, s, request)
634
635 expected := map[string]interface{}{
636 "jsonrpc": "2.0",
637 "id": float64(0), // JSON unmarshals numbers as float64
638 }
639 if diff := compareJSON(expected, response); diff != "" {
640 t.Errorf("Response mismatch:\n%s", diff)
641 }
642
643 // Verify it's a success response (has result, no error)
644 if response["result"] == nil {
645 t.Errorf("Expected result field, got nil")
646 }
647 if response["error"] != nil {
648 t.Errorf("Expected no error, got: %v", response["error"])
649 }
650}
651
652func TestParseErrorReturnsNullID(t *testing.T) {
653 s := makeTestServer(t)

Callers

nothing calls this directly

Calls 5

makeTestServerFunction · 0.85
newRequestFunction · 0.85
executeRequestFunction · 0.85
compareJSONFunction · 0.85
toJSONMethod · 0.80

Tested by

no test coverage detected