github.com/newrelic/newrelic-client-go@v1.1.0/pkg/alerts/events_test.go (about) 1 //go:build unit 2 // +build unit 3 4 package alerts 5 6 import ( 7 "net/http" 8 "testing" 9 10 "github.com/stretchr/testify/assert" 11 ) 12 13 var ( 14 testListAlertEventsResponseJSON = `{ 15 "alert_events": [ 16 { 17 "id": 123, 18 "event_type": "event", 19 "product": "product", 20 "entity_type": "entity", 21 "entity_group_id": 12345, 22 "entity_id": 12345, 23 "priority": "priority", 24 "description": "description", 25 "timestamp": 1575438237690, 26 "incident_id": 12345 27 } 28 ] 29 }` 30 ) 31 32 func TestListAlertEvents(t *testing.T) { 33 t.Parallel() 34 alerts := newMockResponse(t, testListAlertEventsResponseJSON, http.StatusOK) 35 36 expected := []*AlertEvent{ 37 { 38 ID: 123, 39 EventType: "event", 40 Product: "product", 41 EntityType: "entity", 42 EntityGroupID: 12345, 43 EntityID: 12345, 44 Priority: "priority", 45 Description: "description", 46 Timestamp: &testTimestamp, 47 IncidentID: 12345, 48 }, 49 } 50 51 params := &ListAlertEventsParams{ 52 Product: "test", 53 EntityType: "test", 54 EntityGroupID: 12345, 55 EntityID: 12345, 56 EventType: "test", 57 IncidentID: 12345, 58 Page: 1, 59 } 60 61 actual, err := alerts.ListAlertEvents(params) 62 63 assert.NoError(t, err) 64 assert.NotNil(t, actual) 65 assert.Equal(t, expected, actual) 66 }