@@ -133,9 +133,11 @@ func printHTTPResult(result checks.HttpTestResult) string {
133
133
if result .Err != "" {
134
134
str += fmt .Sprintf (" Err: %v\n " , result .Err )
135
135
} else {
136
- str += " Request Headers: \n "
137
- for k , v := range result .RequestHeaders {
138
- str += fmt .Sprintf (" - %v: %v\n " , k , v [0 ])
136
+ if len (result .RequestHeaders ) > 0 {
137
+ str += " Request Headers: \n "
138
+ for k , v := range result .RequestHeaders {
139
+ str += fmt .Sprintf (" - %v: %v\n " , k , v [0 ])
140
+ }
139
141
}
140
142
str += fmt .Sprintf (" Response Status Code: %v\n " , result .StatusCode )
141
143
str += " Response Body: \n "
@@ -210,7 +212,7 @@ func httpRenderer(
210
212
for i , req := range data .HttpTests .Requests {
211
213
ch <- startHttpMsg {path : req .Request .Path , method : req .Request .Method }
212
214
for _ , test := range req .Tests {
213
- ch <- startTestMsg {text : prettyPrintHTTPTest (test )}
215
+ ch <- startTestMsg {text : prettyPrintHTTPTest (test , results [ i ]. Variables )}
214
216
}
215
217
time .Sleep (500 * time .Millisecond )
216
218
for j := range req .Tests {
@@ -243,7 +245,7 @@ func httpRenderer(
243
245
wg .Wait ()
244
246
}
245
247
246
- func prettyPrintHTTPTest (test api.HTTPTest ) string {
248
+ func prettyPrintHTTPTest (test api.HTTPTest , variables map [ string ] string ) string {
247
249
if test .StatusCode != nil {
248
250
return fmt .Sprintf ("Expecting status code: %d" , * test .StatusCode )
249
251
}
@@ -266,13 +268,13 @@ func prettyPrintHTTPTest(test api.HTTPTest) string {
266
268
} else if test .JSONValue .BoolValue != nil {
267
269
val = * test .JSONValue .BoolValue
268
270
}
269
-
270
271
if test .JSONValue .Operator == api .OpEquals {
271
272
op = "to be equal to"
272
273
} else if test .JSONValue .Operator == api .OpGreaterThan {
273
274
op = "to be greater than"
274
275
}
275
- return fmt .Sprintf ("Expecting JSON at %v %s %v" , test .JSONValue .Path , op , val )
276
+ expecting := fmt .Sprintf ("Expecting JSON at %v %s %v" , test .JSONValue .Path , op , val )
277
+ return checks .InterpolateVariables (expecting , variables )
276
278
}
277
279
return ""
278
280
}
0 commit comments