-
Notifications
You must be signed in to change notification settings - Fork 51
/
pagerduty_integration_test.go
68 lines (51 loc) · 2.24 KB
/
pagerduty_integration_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
package signalfx
import (
"context"
"net/http"
"testing"
"github.com/signalfx/signalfx-go/integration"
"github.com/stretchr/testify/assert"
)
func TestCreatePagerDutyIntegration(t *testing.T) {
teardown := setup()
defer teardown()
mux.HandleFunc("/v2/integration", verifyRequest(t, "POST", true, http.StatusOK, nil, "integration/create_pd_success.json"))
result, err := client.CreatePagerDutyIntegration(context.Background(), &integration.PagerDutyIntegration{
Type: "PagerDuty",
})
assert.NoError(t, err, "Unexpected error creating integration")
assert.Equal(t, "string", result.Name, "Name does not match")
}
func TestGetPagerDutyIntegration(t *testing.T) {
teardown := setup()
defer teardown()
mux.HandleFunc("/v2/integration/id", verifyRequest(t, "GET", true, http.StatusOK, nil, "integration/create_pd_success.json"))
result, err := client.GetPagerDutyIntegration(context.Background(), "id")
assert.NoError(t, err, "Unexpected error getting integration")
assert.Equal(t, "string", result.Name, "Name does not match")
}
func TestGetPagerDutyIntegrationByName(t *testing.T) {
teardown := setup()
defer teardown()
mux.HandleFunc("/v2/integration", verifyRequest(t, "GET", true, http.StatusOK, nil, "integration/get_by_name_pd_success.json"))
result, err := client.GetPagerDutyIntegrationByName(context.Background(), "string")
assert.NoError(t, err, "Unexpected error getting integration")
assert.Equal(t, "string", result.Name)
}
func TestUpdatePagerDutyIntegration(t *testing.T) {
teardown := setup()
defer teardown()
mux.HandleFunc("/v2/integration/id", verifyRequest(t, "PUT", true, http.StatusOK, nil, "integration/create_pd_success.json"))
result, err := client.UpdatePagerDutyIntegration(context.Background(), "id", &integration.PagerDutyIntegration{
Type: "PagerDuty",
})
assert.NoError(t, err, "Unexpected error creating integration")
assert.Equal(t, "string", result.Name, "Name does not match")
}
func TestDeletePagerDutyIntegration(t *testing.T) {
teardown := setup()
defer teardown()
mux.HandleFunc("/v2/integration/id", verifyRequest(t, "DELETE", true, http.StatusNoContent, nil, ""))
err := client.DeletePagerDutyIntegration(context.Background(), "id")
assert.NoError(t, err, "Unexpected error creating integration")
}