@@ -34,7 +34,7 @@ func buildCmdArgs(inputs nagiosEnqueueInput) []string {
3434 flag string
3535 val string
3636 }{
37- {"-k" , inputs .routingKey }, {"-t" , inputs .notificationType }, {"-n" , inputs .sourceType }, {"-y" , inputs .dedupKey },
37+ {"-k" , inputs .serviceKey }, {"-t" , inputs .notificationType }, {"-n" , inputs .sourceType }, {"-y" , inputs .incidentKey },
3838 }
3939 for _ , f := range flags {
4040 if f .val != "" {
@@ -56,12 +56,12 @@ func TestNagiosEnqueue_errors(t *testing.T) {
5656 {
5757 name : "missingRequiredFlags" ,
5858 inputs : nagiosEnqueueInput {},
59- expectedError : errors .New ("required flag(s) \" notification-type\" , \" routing -key\" , \" source-type\" not set" ),
59+ expectedError : errors .New ("required flag(s) \" notification-type\" , \" service -key\" , \" source-type\" not set" ),
6060 },
6161 {
6262 name : "invalidNotficationType" ,
6363 inputs : nagiosEnqueueInput {
64- routingKey : "abc" ,
64+ serviceKey : "abc" ,
6565 notificationType : "trigger" ,
6666 sourceType : "host" ,
6767 },
@@ -70,7 +70,7 @@ func TestNagiosEnqueue_errors(t *testing.T) {
7070 {
7171 name : "invalidSourceType" ,
7272 inputs : nagiosEnqueueInput {
73- routingKey : "abc" ,
73+ serviceKey : "abc" ,
7474 notificationType : "PROBLEM" ,
7575 sourceType : "invalidSourceType" ,
7676 },
@@ -79,7 +79,7 @@ func TestNagiosEnqueue_errors(t *testing.T) {
7979 {
8080 name : "hostnameNotSetServiceCustomDetails" ,
8181 inputs : nagiosEnqueueInput {
82- routingKey : "abc" ,
82+ serviceKey : "abc" ,
8383 notificationType : "RECOVERY" ,
8484 sourceType : "service" ,
8585 },
@@ -88,7 +88,7 @@ func TestNagiosEnqueue_errors(t *testing.T) {
8888 {
8989 name : "serviceDescNotSetServiceCustomDetails" ,
9090 inputs : nagiosEnqueueInput {
91- routingKey : "abc" ,
91+ serviceKey : "abc" ,
9292 notificationType : "RECOVERY" ,
9393 sourceType : "service" ,
9494 customFields : map [string ]string {
@@ -100,7 +100,7 @@ func TestNagiosEnqueue_errors(t *testing.T) {
100100 {
101101 name : "serviceStateNotSetServiceCustomDetails" ,
102102 inputs : nagiosEnqueueInput {
103- routingKey : "abc" ,
103+ serviceKey : "abc" ,
104104 notificationType : "RECOVERY" ,
105105 sourceType : "service" ,
106106 customFields : map [string ]string {
@@ -113,7 +113,7 @@ func TestNagiosEnqueue_errors(t *testing.T) {
113113 {
114114 name : "hostnameNotSetHostCustomDetails" ,
115115 inputs : nagiosEnqueueInput {
116- routingKey : "abc" ,
116+ serviceKey : "abc" ,
117117 notificationType : "RECOVERY" ,
118118 sourceType : "host" ,
119119 },
@@ -122,7 +122,7 @@ func TestNagiosEnqueue_errors(t *testing.T) {
122122 {
123123 name : "hoststateNotSetHostCustomDetails" ,
124124 inputs : nagiosEnqueueInput {
125- routingKey : "abc" ,
125+ serviceKey : "abc" ,
126126 notificationType : "RECOVERY" ,
127127 sourceType : "host" ,
128128 customFields : map [string ]string {
@@ -158,7 +158,7 @@ func TestNagiosEnqueue_validInputs(t *testing.T) {
158158 {
159159 name : "validSourceHostInput" ,
160160 cmdInputs : nagiosEnqueueInput {
161- routingKey : "xyz" ,
161+ serviceKey : "xyz" ,
162162 notificationType : "PROBLEM" ,
163163 sourceType : "host" ,
164164 customFields : map [string ]string {
@@ -170,7 +170,7 @@ func TestNagiosEnqueue_validInputs(t *testing.T) {
170170 {
171171 name : "validSourceServiceInput" ,
172172 cmdInputs : nagiosEnqueueInput {
173- routingKey : "xyz" ,
173+ serviceKey : "xyz" ,
174174 notificationType : "PROBLEM" ,
175175 sourceType : "service" ,
176176 customFields : map [string ]string {
@@ -181,12 +181,12 @@ func TestNagiosEnqueue_validInputs(t *testing.T) {
181181 },
182182 },
183183 {
184- name : "userProvidedDedupKey " ,
184+ name : "userProvidedIncidentKey " ,
185185 cmdInputs : nagiosEnqueueInput {
186- routingKey : "xyz" ,
186+ serviceKey : "xyz" ,
187187 notificationType : "PROBLEM" ,
188188 sourceType : "service" ,
189- dedupKey : "somededupkey " ,
189+ incidentKey : "someincidentkey " ,
190190 customFields : map [string ]string {
191191 "HOSTNAME" : "computer.network" ,
192192 "SERVICESTATE" : "down" ,
@@ -214,9 +214,9 @@ func TestNagiosEnqueue_validInputs(t *testing.T) {
214214 cmd := NewNagiosEnqueueCmd (realConfig )
215215 cmd .SetArgs (buildCmdArgs (tt .cmdInputs ))
216216
217- dedupKey := tt .cmdInputs .dedupKey
218- if dedupKey == "" {
219- dedupKey = buildDedupKey (tt .cmdInputs )
217+ incidentKey := tt .cmdInputs .incidentKey
218+ if incidentKey == "" {
219+ incidentKey = buildIncidentKey (tt .cmdInputs )
220220 }
221221
222222 customDetails := map [string ]string {
@@ -227,20 +227,16 @@ func TestNagiosEnqueue_validInputs(t *testing.T) {
227227 }
228228
229229 expectedRequestBody := map [string ]interface {}{
230- "routing_key" : tt .cmdInputs .routingKey ,
231- "event_action" : nagiosToPagerDutyEventType [tt .cmdInputs .notificationType ],
232- "dedup_key" : dedupKey ,
233- "payload" : map [string ]interface {}{
234- "summary" : buildEventDescription (tt .cmdInputs ),
235- "source" : tt .cmdInputs .customFields ["HOSTNAME" ],
236- "severity" : defaultNagiosIntegrationSeverity ,
237- "custom_details" : customDetails ,
238- },
230+ "service_key" : tt .cmdInputs .serviceKey ,
231+ "event_type" : nagiosToPagerDutyEventType [tt .cmdInputs .notificationType ],
232+ "incident_key" : incidentKey ,
233+ "description" : buildEventDescription (tt .cmdInputs ),
234+ "details" : customDetails ,
239235 }
240236
241237 gock .New (cmdutil .GetDefaults ().Address ).
242238 Post ("/send" ).JSON (expectedRequestBody ).
243- Reply (200 ).JSON (map [string ]interface {}{"key" : tt .cmdInputs .routingKey })
239+ Reply (200 ).JSON (map [string ]interface {}{"key" : tt .cmdInputs .serviceKey })
244240
245241 gock .InterceptClient (defaultHTTPClient )
246242
@@ -253,7 +249,7 @@ func TestNagiosEnqueue_validInputs(t *testing.T) {
253249 t .Errorf ("error running command `enqueue`: %v" , err )
254250 }
255251
256- assert .Contains (t , out , fmt .Sprintf (`{"key":"%v"}` , tt .cmdInputs .routingKey ))
252+ assert .Contains (t , out , fmt .Sprintf (`{"key":"%v"}` , tt .cmdInputs .serviceKey ))
257253 })
258254 }
259255}
0 commit comments