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

Function compareJSON

stdio_test.go:450–471  ·  view source on GitHub ↗

compareJSON compares two JSON objects and returns a human-readable diff

(expected, actual map[string]interface{})

Source from the content-addressed store, hash-verified

448
449// compareJSON compares two JSON objects and returns a human-readable diff
450func compareJSON(expected, actual map[string]interface{}) string {
451 var diffs []string
452 for key, expectedVal := range expected {
453 actualVal, exists := actual[key]
454 if !exists {
455 diffs = append(diffs, fmt.Sprintf(" Missing field: %q", key))
456 continue
457 }
458 if fmt.Sprintf("%v", expectedVal) != fmt.Sprintf("%v", actualVal) {
459 diffs = append(diffs, fmt.Sprintf(" Field %q: expected %v, got %v", key, expectedVal, actualVal))
460 }
461 }
462
463 if len(diffs) > 0 {
464 expectedJSON, _ := json.MarshalIndent(expected, " ", " ")
465 actualJSON, _ := json.MarshalIndent(actual, " ", " ")
466 return fmt.Sprintf("Expected:\n %s\n\n Actual:\n %s\n\n Differences:\n%s",
467 expectedJSON, actualJSON, strings.Join(diffs, "\n"))
468 }
469
470 return ""
471}
472
473func TestWebhookUpdate(t *testing.T) {
474 s := makeTestServer(t)

Callers 15

TestStdioHealthRequestFunction · 0.85
TestAdminUsersAddAndListFunction · 0.85
TestAdminUsersGetFunction · 0.85
TestAdminUsersDeleteFunction · 0.85
TestSessionStatusFunction · 0.85
TestChatSendTextFunction · 0.85
TestChatHistoryFunction · 0.85
assertJSONRPC20SuccessFunction · 0.85
assertJSONRPC20ErrorFunction · 0.85
TestWebhookUpdateFunction · 0.85
TestWebhookSetFunction · 0.85
TestWebhookDeleteFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected