@@ -41,12 +41,13 @@ func TestHTTPSuccess(t *testing.T) {
41
41
assert .Equal (HTTPSuccess (mockT2 , httpRedirect , "GET" , "/" , nil ), false )
42
42
assert .True (mockT2 .Failed ())
43
43
44
- mockT3 := new (testing. T )
44
+ mockT3 := new (mockTestingT )
45
45
assert .Equal (HTTPSuccess (
46
46
mockT3 , httpError , "GET" , "/" , nil ,
47
47
"was not expecting a failure here" ,
48
48
), false )
49
49
assert .True (mockT3 .Failed ())
50
+ assert .Contains (mockT3 .errorString (), "was not expecting a failure here" )
50
51
51
52
mockT4 := new (testing.T )
52
53
assert .Equal (HTTPSuccess (mockT4 , httpStatusCode , "GET" , "/" , nil ), false )
@@ -60,12 +61,13 @@ func TestHTTPSuccess(t *testing.T) {
60
61
func TestHTTPRedirect (t * testing.T ) {
61
62
assert := New (t )
62
63
63
- mockT1 := new (testing. T )
64
+ mockT1 := new (mockTestingT )
64
65
assert .Equal (HTTPRedirect (
65
66
mockT1 , httpOK , "GET" , "/" , nil ,
66
67
"was expecting a 3xx status code. Got 200." ,
67
68
), false )
68
69
assert .True (mockT1 .Failed ())
70
+ assert .Contains (mockT1 .errorString (), "was expecting a 3xx status code. Got 200." )
69
71
70
72
mockT2 := new (testing.T )
71
73
assert .Equal (HTTPRedirect (mockT2 , httpRedirect , "GET" , "/" , nil ), true )
@@ -87,12 +89,13 @@ func TestHTTPError(t *testing.T) {
87
89
assert .Equal (HTTPError (mockT1 , httpOK , "GET" , "/" , nil ), false )
88
90
assert .True (mockT1 .Failed ())
89
91
90
- mockT2 := new (testing. T )
92
+ mockT2 := new (mockTestingT )
91
93
assert .Equal (HTTPError (
92
94
mockT2 , httpRedirect , "GET" , "/" , nil ,
93
95
"Expected this request to error out. But it didn't" ,
94
96
), false )
95
97
assert .True (mockT2 .Failed ())
98
+ assert .Contains (mockT2 .errorString (), "Expected this request to error out. But it didn't" )
96
99
97
100
mockT3 := new (testing.T )
98
101
assert .Equal (HTTPError (mockT3 , httpError , "GET" , "/" , nil ), true )
@@ -114,12 +117,13 @@ func TestHTTPStatusCode(t *testing.T) {
114
117
assert .Equal (HTTPStatusCode (mockT2 , httpRedirect , "GET" , "/" , nil , http .StatusSwitchingProtocols ), false )
115
118
assert .True (mockT2 .Failed ())
116
119
117
- mockT3 := new (testing. T )
120
+ mockT3 := new (mockTestingT )
118
121
assert .Equal (HTTPStatusCode (
119
122
mockT3 , httpError , "GET" , "/" , nil , http .StatusSwitchingProtocols ,
120
123
"Expected the status code to be %d" , http .StatusSwitchingProtocols ,
121
124
), false )
122
125
assert .True (mockT3 .Failed ())
126
+ assert .Contains (mockT3 .errorString (), "Expected the status code to be 101" )
123
127
124
128
mockT4 := new (testing.T )
125
129
assert .Equal (HTTPStatusCode (mockT4 , httpStatusCode , "GET" , "/" , nil , http .StatusSwitchingProtocols ), true )
@@ -179,7 +183,7 @@ func TestHTTPRequestWithParams(t *testing.T) {
179
183
180
184
func TestHttpBody (t * testing.T ) {
181
185
assert := New (t )
182
- mockT := new (testing. T )
186
+ mockT := new (mockTestingT )
183
187
184
188
assert .True (HTTPBodyContains (mockT , httpHelloName , "GET" , "/" , url.Values {"name" : []string {"World" }}, "Hello, World!" ))
185
189
assert .True (HTTPBodyContains (mockT , httpHelloName , "GET" , "/" , url.Values {"name" : []string {"World" }}, "World" ))
@@ -191,6 +195,7 @@ func TestHttpBody(t *testing.T) {
191
195
"Expected the request body to not contain 'World'. But it did." ,
192
196
))
193
197
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." )
194
199
195
200
assert .True (HTTPBodyContains (mockT , httpReadBody , "GET" , "/" , nil , "hello" ))
196
201
}
0 commit comments