-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathe2e_webhook_test.go
79 lines (72 loc) · 2.11 KB
/
e2e_webhook_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package pixela
import (
"net/http"
"reflect"
"testing"
)
var webhookHash string
func testE2EWebhookCreate(t *testing.T) {
input := &WebhookCreateInput{
GraphID: String(graphID),
Type: String(WebhookTypeIncrement),
}
result, err := e2eClient.Webhook().Create(input)
if err != nil {
t.Errorf("Webhook.Create() got: %+v\nwant: nil", err)
}
if result.IsSuccess == false {
t.Errorf("Webhook.Create() got: %+v\nwant: true", result)
}
if result.StatusCode != http.StatusOK {
t.Errorf("Webhook.Create() got: %+v\nwant: %d", result, http.StatusOK)
}
webhookHash = result.WebhookHash
}
func testE2EWebhookInvoke(t *testing.T) {
input := &WebhookInvokeInput{WebhookHash: String(webhookHash)}
result, err := e2eClient.Webhook().Invoke(input)
if err != nil {
t.Errorf("Webhook.Invoke() got: %+v\nwant: nil", err)
}
if result.IsSuccess == false {
t.Errorf("Webhook.Invoke() got: %+v\nwant: true", result)
}
if result.StatusCode != http.StatusOK {
t.Errorf("Webhook.Invoke() got: %+v\nwant: %d", result, http.StatusOK)
}
}
func testE2EWebhookGetAll(t *testing.T) {
result, err := e2eClient.Webhook().GetAll()
if err != nil {
t.Errorf("Webhook.GetAll() got: %+v\nwant: nil", err)
}
if result.IsSuccess == false {
t.Errorf("Webhook.GetAll() got: %+v\nwant: true", result)
}
if result.StatusCode != http.StatusOK {
t.Errorf("Webhook.GetAll() got: %+v\nwant: %d", result, http.StatusOK)
}
expected := []WebhookDefinition{
{
GraphID: graphID,
Type: WebhookTypeIncrement,
WebhookHash: webhookHash,
},
}
if reflect.DeepEqual(result.Webhooks, expected) == false {
t.Errorf("Webhook.GetAll() got: %+v\nwant: %+v", result.Webhooks, expected)
}
}
func testE2EWebhookDelete(t *testing.T) {
input := &WebhookDeleteInput{WebhookHash: String(webhookHash)}
result, err := e2eClient.Webhook().Delete(input)
if err != nil {
t.Errorf("Webhook.Delete() got: %+v\nwant: nil", err)
}
if result.IsSuccess == false {
t.Errorf("Webhook.Delete() got: %+v\nwant: true", result)
}
if result.StatusCode != http.StatusOK {
t.Errorf("Webhook.Delete() got: %+v\nwant: %d", result, http.StatusOK)
}
}