@@ -47,7 +47,7 @@ func TestAlertCmd(t *testing.T) {
4747 w .Write ([]byte (`{"status":"success","data":{"groups":[]}}` ))
4848 })),
4949 args : []string {"run" , "../main.go" , "alert" },
50- expected : "[OK] - No alerts defined\n " ,
50+ expected : "[OK] - No alerts defined | total=0 firing=0 pending=0 inactive=0 \n " ,
5151 },
5252 {
5353 name : "alert-none-with-problems" ,
@@ -56,7 +56,7 @@ func TestAlertCmd(t *testing.T) {
5656 w .Write ([]byte (`{"status":"success","data":{"groups":[]}}` ))
5757 })),
5858 args : []string {"run" , "../main.go" , "alert" , "--problems" },
59- expected : "[OK] - No alerts defined\n " ,
59+ expected : "[OK] - No alerts defined | total=0 firing=0 pending=0 inactive=0 \n " ,
6060 },
6161 {
6262 name : "alert-none-with-no-state" ,
@@ -65,7 +65,7 @@ func TestAlertCmd(t *testing.T) {
6565 w .Write ([]byte (`{"status":"success","data":{"groups":[]}}` ))
6666 })),
6767 args : []string {"run" , "../main.go" , "alert" , "--no-alerts-state" , "3" },
68- expected : "[UNKNOWN] - No alerts defined\n exit status 3\n " ,
68+ expected : "[UNKNOWN] - No alerts defined | total=0 firing=0 pending=0 inactive=0 \n exit status 3\n " ,
6969 },
7070 {
7171 name : "alert-none-with-name" ,
@@ -74,7 +74,7 @@ func TestAlertCmd(t *testing.T) {
7474 w .Write ([]byte (`{"status":"success","data":{"groups":[]}}` ))
7575 })),
7676 args : []string {"run" , "../main.go" , "alert" , "--name" , "MyPreciousAlert" },
77- expected : "[UNKNOWN] - No such alert defined\n exit status 3\n " ,
77+ expected : "[UNKNOWN] - No such alert defined | total=0 firing=0 pending=0 inactive=0 \n exit status 3\n " ,
7878 },
7979 {
8080 name : "alert-default" ,
@@ -116,6 +116,7 @@ exit status 2
116116 args : []string {"run" , "../main.go" , "alert" , "--problems" , "-g" , "TLS" },
117117 expected : `[CRITICAL] - 1 Alerts: 1 Firing - 0 Pending - 0 Inactive
118118\_ [CRITICAL] [BlackboxTLS] - Job: [blackbox] on Instance: [https://localhost:443] is firing - value: -6065338.00
119+ |total=1 firing=1 pending=0 inactive=0
119120
120121exit status 2
121122` ,
@@ -144,6 +145,7 @@ exit status 2
144145 args : []string {"run" , "../main.go" , "alert" , "--problems" , "--exclude-alert" , "Sql.*DeniedRate" },
145146 expected : `[CRITICAL] - 1 Alerts: 1 Firing - 0 Pending - 0 Inactive
146147\_ [CRITICAL] [BlackboxTLS] - Job: [blackbox] on Instance: [https://localhost:443] is firing - value: -6065338.00
148+ |total=1 firing=1 pending=0 inactive=0
147149
148150exit status 2
149151` ,
@@ -163,17 +165,27 @@ exit status 2
163165 w .WriteHeader (http .StatusOK )
164166 w .Write (loadTestdata (alertTestDataSet2 ))
165167 })),
166- args : []string {"run" , "../main.go" , "alert" , "--name" , "NoSuchAlert" },
167- expected : "[UNKNOWN] - 0 Alerts: 0 Firing - 0 Pending - 0 Inactive\n \n exit status 3\n " ,
168+ args : []string {"run" , "../main.go" , "alert" , "--name" , "NoSuchAlert" },
169+ expected : `[UNKNOWN] - 0 Alerts: 0 Firing - 0 Pending - 0 Inactive
170+ \_ [UNKNOWN] No alerts retrieved
171+ |total=0 firing=0 pending=0 inactive=0
172+
173+ exit status 3
174+ ` ,
168175 },
169176 {
170177 name : "alert-inactive-with-problems" ,
171178 server : httptest .NewServer (http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
172179 w .WriteHeader (http .StatusOK )
173180 w .Write (loadTestdata (alertTestDataSet2 ))
174181 })),
175- args : []string {"run" , "../main.go" , "alert" , "--name" , "InactiveAlert" , "--problems" },
176- expected : "[UNKNOWN] - 0 Alerts: 0 Firing - 0 Pending - 0 Inactive\n \n exit status 3\n " ,
182+ args : []string {"run" , "../main.go" , "alert" , "--name" , "InactiveAlert" , "--problems" },
183+ expected : `[UNKNOWN] - 0 Alerts: 0 Firing - 0 Pending - 0 Inactive
184+ \_ [UNKNOWN] No alerts retrieved
185+ |total=0 firing=0 pending=0 inactive=0
186+
187+ exit status 3
188+ ` ,
177189 },
178190 {
179191 name : "alert-multiple-alerts" ,
@@ -211,7 +223,7 @@ exit status 2
211223 w .Write (loadTestdata (alertTestDataSet2 ))
212224 })),
213225 args : []string {"run" , "../main.go" , "alert" , "--name" , "InactiveAlert" },
214- expected : "[OK] - 1 Alerts: 0 Firing - 0 Pending - 1 Inactive\n \\ _ [OK] [InactiveAlert] is inactive\n |firing=0 pending=0 inactive=1\n \n " ,
226+ expected : "[OK] - 1 Alerts: 0 Firing - 0 Pending - 1 Inactive\n \\ _ [OK] [InactiveAlert] is inactive\n |total=1 firing=0 pending=0 inactive=1\n \n " ,
215227 },
216228 {
217229 name : "alert-recording-rule" ,
@@ -220,7 +232,7 @@ exit status 2
220232 w .Write (loadTestdata (alertTestDataSet4 ))
221233 })),
222234 args : []string {"run" , "../main.go" , "alert" , "--name" , "InactiveAlert" },
223- expected : "[OK] - 1 Alerts: 0 Firing - 0 Pending - 1 Inactive\n \\ _ [OK] [InactiveAlert] is inactive\n |firing=0 pending=0 inactive=1\n \n " ,
235+ expected : "[OK] - 1 Alerts: 0 Firing - 0 Pending - 1 Inactive\n \\ _ [OK] [InactiveAlert] is inactive\n |total=1 firing=0 pending=0 inactive=1\n \n " ,
224236 },
225237 }
226238
0 commit comments