@@ -41,9 +41,13 @@ func TestHTTPSuccess(t *testing.T) {
4141 assert .Equal (HTTPSuccess (mockT2 , httpRedirect , "GET" , "/" , nil ), false )
4242 assert .True (mockT2 .Failed ())
4343
44- mockT3 := new (testing.T )
45- assert .Equal (HTTPSuccess (mockT3 , httpError , "GET" , "/" , nil ), false )
44+ mockT3 := new (mockTestingT )
45+ assert .Equal (HTTPSuccess (
46+ mockT3 , httpError , "GET" , "/" , nil ,
47+ "was not expecting a failure here" ,
48+ ), false )
4649 assert .True (mockT3 .Failed ())
50+ assert .Contains (mockT3 .errorString (), "was not expecting a failure here" )
4751
4852 mockT4 := new (testing.T )
4953 assert .Equal (HTTPSuccess (mockT4 , httpStatusCode , "GET" , "/" , nil ), false )
@@ -57,9 +61,13 @@ func TestHTTPSuccess(t *testing.T) {
5761func TestHTTPRedirect (t * testing.T ) {
5862 assert := New (t )
5963
60- mockT1 := new (testing.T )
61- assert .Equal (HTTPRedirect (mockT1 , httpOK , "GET" , "/" , nil ), false )
64+ mockT1 := new (mockTestingT )
65+ assert .Equal (HTTPRedirect (
66+ mockT1 , httpOK , "GET" , "/" , nil ,
67+ "was expecting a 3xx status code. Got 200." ,
68+ ), false )
6269 assert .True (mockT1 .Failed ())
70+ assert .Contains (mockT1 .errorString (), "was expecting a 3xx status code. Got 200." )
6371
6472 mockT2 := new (testing.T )
6573 assert .Equal (HTTPRedirect (mockT2 , httpRedirect , "GET" , "/" , nil ), true )
@@ -81,9 +89,13 @@ func TestHTTPError(t *testing.T) {
8189 assert .Equal (HTTPError (mockT1 , httpOK , "GET" , "/" , nil ), false )
8290 assert .True (mockT1 .Failed ())
8391
84- mockT2 := new (testing.T )
85- assert .Equal (HTTPError (mockT2 , httpRedirect , "GET" , "/" , nil ), false )
92+ mockT2 := new (mockTestingT )
93+ assert .Equal (HTTPError (
94+ mockT2 , httpRedirect , "GET" , "/" , nil ,
95+ "Expected this request to error out. But it didn't" ,
96+ ), false )
8697 assert .True (mockT2 .Failed ())
98+ assert .Contains (mockT2 .errorString (), "Expected this request to error out. But it didn't" )
8799
88100 mockT3 := new (testing.T )
89101 assert .Equal (HTTPError (mockT3 , httpError , "GET" , "/" , nil ), true )
@@ -105,9 +117,13 @@ func TestHTTPStatusCode(t *testing.T) {
105117 assert .Equal (HTTPStatusCode (mockT2 , httpRedirect , "GET" , "/" , nil , http .StatusSwitchingProtocols ), false )
106118 assert .True (mockT2 .Failed ())
107119
108- mockT3 := new (testing.T )
109- assert .Equal (HTTPStatusCode (mockT3 , httpError , "GET" , "/" , nil , http .StatusSwitchingProtocols ), false )
120+ mockT3 := new (mockTestingT )
121+ assert .Equal (HTTPStatusCode (
122+ mockT3 , httpError , "GET" , "/" , nil , http .StatusSwitchingProtocols ,
123+ "Expected the status code to be %d" , http .StatusSwitchingProtocols ,
124+ ), false )
110125 assert .True (mockT3 .Failed ())
126+ assert .Contains (mockT3 .errorString (), "Expected the status code to be 101" )
111127
112128 mockT4 := new (testing.T )
113129 assert .Equal (HTTPStatusCode (mockT4 , httpStatusCode , "GET" , "/" , nil , http .StatusSwitchingProtocols ), true )
@@ -167,15 +183,19 @@ func TestHTTPRequestWithParams(t *testing.T) {
167183
168184func TestHttpBody (t * testing.T ) {
169185 assert := New (t )
170- mockT := new (testing. T )
186+ mockT := new (mockTestingT )
171187
172188 assert .True (HTTPBodyContains (mockT , httpHelloName , "GET" , "/" , url.Values {"name" : []string {"World" }}, "Hello, World!" ))
173189 assert .True (HTTPBodyContains (mockT , httpHelloName , "GET" , "/" , url.Values {"name" : []string {"World" }}, "World" ))
174190 assert .False (HTTPBodyContains (mockT , httpHelloName , "GET" , "/" , url.Values {"name" : []string {"World" }}, "world" ))
175191
176192 assert .False (HTTPBodyNotContains (mockT , httpHelloName , "GET" , "/" , url.Values {"name" : []string {"World" }}, "Hello, World!" ))
177- assert .False (HTTPBodyNotContains (mockT , httpHelloName , "GET" , "/" , url.Values {"name" : []string {"World" }}, "World" ))
193+ assert .False (HTTPBodyNotContains (
194+ mockT , httpHelloName , "GET" , "/" , url.Values {"name" : []string {"World" }}, "World" ,
195+ "Expected the request body to not contain 'World'. But it did." ,
196+ ))
178197 assert .True (HTTPBodyNotContains (mockT , httpHelloName , "GET" , "/" , url.Values {"name" : []string {"World" }}, "world" ))
198+ assert .Contains (mockT .errorString (), "Expected the request body to not contain 'World'. But it did." )
179199
180200 assert .True (HTTPBodyContains (mockT , httpReadBody , "GET" , "/" , nil , "hello" ))
181201}
0 commit comments