-
Notifications
You must be signed in to change notification settings - Fork 53
/
integration_test.go
52 lines (38 loc) · 1.56 KB
/
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
package signalfx
import (
"context"
"net/http"
"testing"
"github.com/stretchr/testify/assert"
)
func TestDeleteIntegration(t *testing.T) {
teardown := setup()
defer teardown()
mux.HandleFunc("/v2/integration/string", verifyRequest(t, "DELETE", true, http.StatusNoContent, nil, ""))
err := client.DeleteIntegration(context.Background(), "string")
assert.NoError(t, err, "Unexpected error deleting integration")
}
func TestDeleteMissingIntegration(t *testing.T) {
teardown := setup()
defer teardown()
mux.HandleFunc("/v2/integration/string", verifyRequest(t, "DELETE", true, http.StatusNotFound, nil, ""))
err := client.DeleteIntegration(context.Background(), "string")
assert.Error(t, err, "Should get error error deleting missing integration")
}
func TestGetIntegration(t *testing.T) {
teardown := setup()
defer teardown()
mux.HandleFunc("/v2/integration/string", verifyRequest(t, "GET", true, http.StatusOK, nil, "integration/get_success.json"))
result, err := client.GetIntegration(context.Background(), "string")
assert.NoError(t, err, "Unexpected error getting integration")
id := result["id"].(string)
assert.Equal(t, id, "string", "Missing ID")
}
func TestGetMissingIntegration(t *testing.T) {
teardown := setup()
defer teardown()
mux.HandleFunc("/v2/integration/string", verifyRequest(t, "GET", true, http.StatusNotFound, nil, ""))
result, err := client.GetIntegration(context.Background(), "string")
assert.Error(t, err, "Should get an error getting missing integration")
assert.Nil(t, result, "Should get a nil result from a missing integration")
}