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

Function TestWebhookDelete

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

Source from the content-addressed store, hash-verified

548}
549
550func TestWebhookDelete(t *testing.T) {
551 s := makeTestServer(t)
552
553 // Create a user with webhook configured
554 addRequest := newRequest("1", "admin.users.add", map[string]interface{}{
555 "adminToken": "test-admin-token",
556 "name": "DeleteUser",
557 "token": "delete-token",
558 }).toJSON(t)
559 executeRequest(t, s, addRequest)
560
561 // Set a webhook first
562 setRequest := newRequest("2", "webhook.set", map[string]interface{}{
563 "token": "delete-token",
564 "webhookurl": "http://example.com/webhook",
565 "events": []string{"Message"},
566 }).toJSON(t)
567 executeRequest(t, s, setRequest)
568
569 // Delete webhook
570 deleteRequest := newRequest("3", "webhook.delete", map[string]interface{}{
571 "token": "delete-token",
572 }).toJSON(t)
573 deleteResponse := executeRequest(t, s, deleteRequest)
574
575 expectedDelete := map[string]interface{}{
576 "jsonrpc": "2.0",
577 "id": "3",
578 }
579 if diff := compareJSON(expectedDelete, deleteResponse); diff != "" {
580 t.Errorf("Delete response mismatch:\n%s", diff)
581 }
582
583 // Verify webhook is cleared
584 getRequest := newRequest("4", "webhook.get", map[string]interface{}{
585 "token": "delete-token",
586 }).toJSON(t)
587 getResponse := executeRequest(t, s, getRequest)
588
589 expectedGet := map[string]interface{}{
590 "jsonrpc": "2.0",
591 "id": "4",
592 }
593 if diff := compareJSON(expectedGet, getResponse); diff != "" {
594 t.Errorf("Get response mismatch:\n%s", diff)
595 }
596
597 data := getResponse["result"].(map[string]interface{})
598 webhook := data["webhook"].(string)
599 if webhook != "" {
600 t.Errorf("Expected empty webhook after delete, got: %s", webhook)
601 }
602}
603
604func TestNumericRequestID(t *testing.T) {
605 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