@@ -133,9 +133,11 @@ func printHTTPResult(result checks.HttpTestResult) string {
133133 if result .Err != "" {
134134 str += fmt .Sprintf (" Err: %v\n " , result .Err )
135135 } 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+ }
139141 }
140142 str += fmt .Sprintf (" Response Status Code: %v\n " , result .StatusCode )
141143 str += " Response Body: \n "
@@ -210,7 +212,7 @@ func httpRenderer(
210212 for i , req := range data .HttpTests .Requests {
211213 ch <- startHttpMsg {path : req .Request .Path , method : req .Request .Method }
212214 for _ , test := range req .Tests {
213- ch <- startTestMsg {text : prettyPrintHTTPTest (test )}
215+ ch <- startTestMsg {text : prettyPrintHTTPTest (test , results [ i ]. Variables )}
214216 }
215217 time .Sleep (500 * time .Millisecond )
216218 for j := range req .Tests {
@@ -243,7 +245,7 @@ func httpRenderer(
243245 wg .Wait ()
244246}
245247
246- func prettyPrintHTTPTest (test api.HTTPTest ) string {
248+ func prettyPrintHTTPTest (test api.HTTPTest , variables map [ string ] string ) string {
247249 if test .StatusCode != nil {
248250 return fmt .Sprintf ("Expecting status code: %d" , * test .StatusCode )
249251 }
@@ -266,13 +268,13 @@ func prettyPrintHTTPTest(test api.HTTPTest) string {
266268 } else if test .JSONValue .BoolValue != nil {
267269 val = * test .JSONValue .BoolValue
268270 }
269-
270271 if test .JSONValue .Operator == api .OpEquals {
271272 op = "to be equal to"
272273 } else if test .JSONValue .Operator == api .OpGreaterThan {
273274 op = "to be greater than"
274275 }
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 )
276278 }
277279 return ""
278280}
0 commit comments