forked from signalfx/signalfx-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
incident_test.go
63 lines (55 loc) · 1.92 KB
/
incident_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
package signalfx
import (
"context"
"net/http"
"testing"
"github.com/signalfx/signalfx-go/detector"
"github.com/stretchr/testify/assert"
)
func TestGetIncident(t *testing.T) {
teardown := setup()
defer teardown()
mux.HandleFunc("/v2/incident/string", verifyRequest(t, "GET", true, http.StatusOK, nil, "incident/get_incident.json"))
result, err := client.GetIncident(context.Background(), "string")
expected := detector.Incident{
Active: true,
AnomalyState: "ANOMALOUS",
DetectLabel: "string",
DetectorId: "string",
Events: []*detector.Event{
{
AnomalyState: "ANOMALOUS",
DetectLabel: "string",
DetectorId: "string",
DetectorName: "string",
EventAnnotations: &map[string]interface{}{},
Id: "string",
IncidentId: "string",
Inputs: &map[string]interface{}{
"A": float64(5),
"B": float64(6),
},
Severity: "Critical",
Timestamp: 1557484230000,
},
},
IncidentId: "string",
IsMuted: true,
Severity: "Critical",
TriggeredNotificationSent: true,
TriggeredWhileMuted: true,
}
assert.NoError(t, err, "Unexpected error getting incident")
assert.Equal(t, expected, *result, "Extected incident does not match the actual incident reponse")
}
func TestGetIncidents(t *testing.T) {
teardown := setup()
defer teardown()
mux.HandleFunc("/v2/incident", verifyRequest(t, "GET", true, http.StatusOK, nil, "incident/get_incidents.json"))
result, err := client.GetIncidents(context.Background(), false, 10, "", 0)
assert.NoError(t, err, "Unexpected error getting all incidents")
assert.Equal(t, len(result), 2, "Incorrect number of incidents returned")
assert.Equal(t, result[0].IncidentId, "string", "Name does not match")
assert.Equal(t, result[0].Active, true, "Active field does not match")
assert.Equal(t, result[1].IncidentId, "string1", "Name does not match")
}