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

Function TestNumericRequestID

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

Source from the content-addressed store, hash-verified

602}
603
604func TestNumericRequestID(t *testing.T) {
605 s := makeTestServer(t)
606
607 // Send request with numeric ID (JSON-RPC 2.0 compliant)
608 request := newRequest(42, "health", nil).toJSON(t)
609 response := executeRequest(t, s, request)
610
611 expected := map[string]interface{}{
612 "jsonrpc": "2.0",
613 "id": float64(42), // JSON unmarshals numbers as float64
614 }
615 if diff := compareJSON(expected, response); diff != "" {
616 t.Errorf("Response mismatch:\n%s", diff)
617 }
618
619 // Verify it's a success response (has result, no error)
620 if response["result"] == nil {
621 t.Errorf("Expected result field, got nil")
622 }
623 if response["error"] != nil {
624 t.Errorf("Expected no error, got: %v", response["error"])
625 }
626}
627
628func TestNumericZeroRequestID(t *testing.T) {
629 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