@@ -146,44 +146,35 @@ func interpolateJSONStrings(value any, variables map[string]string) any {
146146}
147147
148148func prettyPrintHTTPTest (test api.HTTPRequestTest , variables map [string ]string ) string {
149+ var descriptions []string
149150 if test .StatusCode != nil {
150- return fmt .Sprintf ("Expecting status code: %d" , * test .StatusCode )
151+ descriptions = append ( descriptions , fmt .Sprintf ("Expecting status code: %d" , * test .StatusCode ) )
151152 }
152153 if test .BodyContains != nil {
153- interpolated := InterpolateVariables (* test .BodyContains , variables )
154- return fmt .Sprintf ("Expecting response body to contain: %s" , interpolated )
154+ descriptions = append (descriptions , fmt .Sprintf ("Expecting response body to contain: %s" , * test .BodyContains ))
155155 }
156156 if test .BodyContainsNone != nil {
157- interpolated := InterpolateVariables (* test .BodyContainsNone , variables )
158- return fmt .Sprintf ("Expecting response body to not contain: %s" , interpolated )
157+ descriptions = append (descriptions , fmt .Sprintf ("Expecting response body to not contain: %s" , * test .BodyContainsNone ))
159158 }
160159 if test .HeadersEqual != nil {
161- interpolatedKey := InterpolateVariables (test .HeadersEqual .Key , variables )
162- interpolatedValue := InterpolateVariables (test .HeadersEqual .Value , variables )
163- return fmt .Sprintf ("Expecting header to equal: '%s: %v'" , interpolatedKey , interpolatedValue )
160+ descriptions = append (descriptions , fmt .Sprintf ("Expecting header to equal: '%s: %v'" , test .HeadersEqual .Key , test .HeadersEqual .Value ))
164161 }
165162 if test .HeadersContain != nil {
166- interpolatedKey := InterpolateVariables (test .HeadersContain .Key , variables )
167- interpolatedValue := InterpolateVariables (test .HeadersContain .Value , variables )
168- return fmt .Sprintf ("Expecting header to contain: '%s: %v'" , interpolatedKey , interpolatedValue )
163+ descriptions = append (descriptions , fmt .Sprintf ("Expecting header to contain: '%s: %v'" , test .HeadersContain .Key , test .HeadersContain .Value ))
169164 }
170165 if test .TrailersEqual != nil {
171- interpolatedKey := InterpolateVariables (test .TrailersEqual .Key , variables )
172- interpolatedValue := InterpolateVariables (test .TrailersEqual .Value , variables )
173- return fmt .Sprintf ("Expecting trailer to equal: '%s: %v'" , interpolatedKey , interpolatedValue )
166+ descriptions = append (descriptions , fmt .Sprintf ("Expecting trailer to equal: '%s: %v'" , test .TrailersEqual .Key , test .TrailersEqual .Value ))
174167 }
175168 if test .TrailersContain != nil {
176- interpolatedKey := InterpolateVariables (test .TrailersContain .Key , variables )
177- interpolatedValue := InterpolateVariables (test .TrailersContain .Value , variables )
178- return fmt .Sprintf ("Expecting trailer to contain: '%s: %v'" , interpolatedKey , interpolatedValue )
169+ descriptions = append (descriptions , fmt .Sprintf ("Expecting trailer to contain: '%s: %v'" , test .TrailersContain .Key , test .TrailersContain .Value ))
179170 }
180171 if test .JSONValue != nil {
181172 var val any
182173 switch {
183174 case test .JSONValue .IntValue != nil :
184175 val = * test .JSONValue .IntValue
185176 case test .JSONValue .StringValue != nil :
186- val = * test .JSONValue .StringValue
177+ val = InterpolateVariables ( * test .JSONValue .StringValue , variables )
187178 case test .JSONValue .BoolValue != nil :
188179 val = * test .JSONValue .BoolValue
189180 }
@@ -201,9 +192,9 @@ func prettyPrintHTTPTest(test api.HTTPRequestTest, variables map[string]string)
201192 }
202193
203194 expecting := fmt .Sprintf ("Expecting JSON at %v %s %v" , test .JSONValue .Path , op , val )
204- return InterpolateVariables ( expecting , variables )
195+ descriptions = append ( descriptions , expecting )
205196 }
206- return ""
197+ return strings . Join ( descriptions , " \n " )
207198}
208199
209200// Return a capped string representation of the response body.
@@ -267,7 +258,7 @@ func parseVariables(body []byte, vardefs []api.HTTPRequestResponseVariable, vari
267258func parseHeaderVariables (headers map [string ]string , vardefs []api.HTTPRequestResponseHeaderVariable , variables map [string ]string ) error {
268259 for _ , vardef := range vardefs {
269260 headerValue , ok := findHeaderValue (headers , vardef .Header )
270- if ! ok || headerValue == "" {
261+ if ! ok {
271262 continue
272263 }
273264
0 commit comments