@@ -119,7 +119,12 @@ func TestCmpResponse(tt *testing.T) {
119119\s+Response.Status: values differ
120120\s+got: 242
121121\s+expected: 243` ,
122- " Raw received body: `text response\n " , // check the complete body is shown
122+ `~ Received response:
123+ \s+\x60(?s:.+?)
124+ \s+
125+ \s+text response
126+ \s+\x60
127+ ` , // check the complete body is shown
123128 },
124129 },
125130 {
@@ -142,10 +147,15 @@ func TestCmpResponse(tt *testing.T) {
142147 ExpectedResp : tdhttp.Response {},
143148 ExpectedLogs : []string {
144149 `~ Failed test 'body should be empty'
145- \s+Response.Body: not empty
146- \s+got: (?s:.*?)
150+ \s+Response.Body is not empty
151+ \s+got: not empty
147152\s+expected: empty` ,
148- "text response" , // check the response is shown (in got:)
153+ `~ Received response:
154+ \s+\x60(?s:.+?)
155+ \s+
156+ \s+text response
157+ \s+\x60
158+ ` , // check the complete body is shown
149159 },
150160 },
151161 {
@@ -173,7 +183,12 @@ func TestCmpResponse(tt *testing.T) {
173183\s+unmarshal\(Response\.Body\): should NOT be an error
174184\s+got: .*Cmp(Response|Body) only accepts expected(Resp\.)?Body be a \[\]byte, a string or a TestDeep operator allowing to match these types, but not type int.*
175185\s+expected: nil` ,
176- " Raw received body: `text response\n " , // check the complete body is shown
186+ `~ Received response:
187+ \s+\x60(?s:.+?)
188+ \s+
189+ \s+text response
190+ \s+\x60
191+ ` , // check the complete body is shown
177192 },
178193 },
179194 // Empty success
@@ -261,7 +276,12 @@ func TestCmpJSONResponse(tt *testing.T) {
261276\s+unmarshal\(Response\.Body\): should NOT be an error
262277\s+got: .*cannot unmarshal object into Go value of type int.*
263278\s+expected: nil` ,
264- `~ Raw received body: \x60\{"name":"Bob"\}\n\s+\x60` , // check the complete body is shown
279+ `~ Received response:
280+ \s+\x60(?s:.+?)
281+ \s+
282+ \s+\{"name":"Bob"\}
283+ \s+\x60
284+ ` , // check the complete body is shown
265285 },
266286 },
267287 } {
@@ -405,7 +425,12 @@ func TestCmpXMLResponse(tt *testing.T) {
405425\s+unmarshal\(Response\.Body\): should NOT be an error
406426\s+got: .*unknown type func\(\).*
407427\s+expected: nil` ,
408- `~ Raw received body: \x60<XResp><name>Bob</name></XResp>\n\s+\x60` , // check the complete body is shown
428+ `~ Received response:
429+ \s+\x60(?s:.+?)
430+ \s+
431+ \s+<XResp><name>Bob</name></XResp>
432+ \s+\x60
433+ ` , // check the complete body is shown
409434 },
410435 },
411436 } {
@@ -421,6 +446,12 @@ func TestCmpXMLResponse(tt *testing.T) {
421446 }
422447}
423448
449+ var logsViz = strings .NewReplacer (
450+ " " , "·" ,
451+ "\t " , "→" ,
452+ "\r " , "<cr>" ,
453+ )
454+
424455func testLogs (t * td.T , mockT * tdutil.T , curTest CmpResponseTest ) {
425456 t .Helper ()
426457
@@ -440,7 +471,7 @@ func testLogs(t *td.T, mockT *tdutil.T, curTest CmpResponseTest) {
440471 }
441472
442473 if dumpLogs {
443- t .Errorf (`Test logs: "%s"` , mockT .LogBuf ())
474+ t .Errorf (`Test logs: "%s"` , logsViz . Replace ( mockT .LogBuf () ))
444475 }
445476}
446477
@@ -637,7 +668,7 @@ func TestMux(t *testing.T) {
637668 t .False (ok )
638669 t .True (mockT .Failed ())
639670 t .Contains (mockT .LogBuf (), "nothing has been set during unmarshaling" )
640- t .Contains (mockT .LogBuf (), "Raw received body :" )
671+ t .Contains (mockT .LogBuf (), "Received response :" )
641672 })
642673 })
643674
@@ -713,7 +744,7 @@ func TestMux(t *testing.T) {
713744 "Cannot guess the body expected type as Any TestDeep" )
714745 t .Contains (mockT .LogBuf (),
715746 "You can try All(Isa(EXPECTED_TYPE), Any(…)) to disambiguate…" )
716- t .Contains (mockT .LogBuf (), "Raw received body :" )
747+ t .Contains (mockT .LogBuf (), "Received response :" )
717748 })
718749 })
719750}
0 commit comments