-
Notifications
You must be signed in to change notification settings - Fork 53
/
gcp_integration_test.go
60 lines (46 loc) · 2.04 KB
/
gcp_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
package signalfx
import (
"context"
"net/http"
"testing"
"github.com/signalfx/signalfx-go/integration"
"github.com/stretchr/testify/assert"
)
func TestCreateGCPIntegration(t *testing.T) {
teardown := setup()
defer teardown()
mux.HandleFunc("/v2/integration", verifyRequest(t, "POST", true, http.StatusOK, nil, "integration/create_gcp_success.json"))
result, err := client.CreateGCPIntegration(context.Background(), &integration.GCPIntegration{
Type: "GCP",
})
assert.NoError(t, err, "Unexpected error creating integration")
assert.Equal(t, "string", result.Name, "Name does not match")
assert.Equal(t, integration.FiveMinutely, *result.PollRate, "PollRate does not match")
assert.Equal(t, true, result.UseMetricSourceProjectForQuota, "UseMetricSourceProjectForQuota does not match")
assert.Equal(t, int64(300000), result.PollRateMs, "PollRateMs does not match")
}
func TestGetGCPIntegration(t *testing.T) {
teardown := setup()
defer teardown()
mux.HandleFunc("/v2/integration/id", verifyRequest(t, "GET", true, http.StatusOK, nil, "integration/create_gcp_success.json"))
result, err := client.GetGCPIntegration(context.Background(), "id")
assert.NoError(t, err, "Unexpected error getting integration")
assert.Equal(t, "string", result.Name, "Name does not match")
}
func TestUpdateGCPIntegration(t *testing.T) {
teardown := setup()
defer teardown()
mux.HandleFunc("/v2/integration/id", verifyRequest(t, "PUT", true, http.StatusOK, nil, "integration/create_gcp_success.json"))
result, err := client.UpdateGCPIntegration(context.Background(), "id", &integration.GCPIntegration{
Type: "GCP",
})
assert.NoError(t, err, "Unexpected error creating integration")
assert.Equal(t, "string", result.Name, "Name does not match")
}
func TestDeleteGCPIntegration(t *testing.T) {
teardown := setup()
defer teardown()
mux.HandleFunc("/v2/integration/id", verifyRequest(t, "DELETE", true, http.StatusNoContent, nil, ""))
err := client.DeleteGCPIntegration(context.Background(), "id")
assert.NoError(t, err, "Unexpected error creating integration")
}