MCPcopy Create free account
hub / github.com/devaccuracy/ledgerforge / TestSendWebhook

Function TestSendWebhook

webhooks_test.go:42–80  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

40}
41
42func TestSendWebhook(t *testing.T) {
43 mr, err := miniredis.Run()
44 if err != nil {
45 t.Fatalf("an error '%s' occurred when starting miniredis", err)
46 }
47 defer mr.Close()
48
49 cnf := &config.Configuration{
50 Redis: config.RedisConfig{
51 Dns: mr.Addr(),
52 },
53 Queue: config.QueueConfig{
54 WebhookQueue: "webhook_queue",
55 NumberOfQueues: 1,
56 },
57 Notification: config.Notification{
58 Webhook: config.WebhookConfig{
59 Url: "http://localhost:8080",
60 },
61 },
62 }
63 config.ConfigStore.Store(cnf)
64
65 testData := NewWebhook{
66 Event: "transaction.queued",
67 Payload: getTransactionMock(10000, false),
68 }
69 ledgerforge, err := NewLedgerForge(nil)
70 assert.NoError(t, err)
71
72 err = ledgerforge.SendWebhook(testData)
73 assert.NoError(t, err)
74
75 // Verify that the task was enqueued
76 assert.NoError(t, err)
77 tasks := mr.Keys()
78 assert.NoError(t, err)
79 assert.NotEmpty(t, tasks)
80}
81
82func TestConnectionReuse(t *testing.T) {
83 // Track unique connections

Callers

nothing calls this directly

Calls 5

SendWebhookMethod · 0.95
getTransactionMockFunction · 0.85
NewLedgerForgeFunction · 0.85
KeysMethod · 0.80
CloseMethod · 0.45

Tested by

no test coverage detected