@@ -37,19 +37,19 @@ func TestStripSlashes(t *testing.T) {
37
37
defer ts .Close ()
38
38
39
39
if _ , resp := testRequest (t , ts , "GET" , "/" , nil ); resp != "root" {
40
- t .Fatalf (resp )
40
+ t .Fatal (resp )
41
41
}
42
42
if _ , resp := testRequest (t , ts , "GET" , "//" , nil ); resp != "root" {
43
- t .Fatalf (resp )
43
+ t .Fatal (resp )
44
44
}
45
45
if _ , resp := testRequest (t , ts , "GET" , "/accounts/admin" , nil ); resp != "admin" {
46
- t .Fatalf (resp )
46
+ t .Fatal (resp )
47
47
}
48
48
if _ , resp := testRequest (t , ts , "GET" , "/accounts/admin/" , nil ); resp != "admin" {
49
- t .Fatalf (resp )
49
+ t .Fatal (resp )
50
50
}
51
51
if _ , resp := testRequest (t , ts , "GET" , "/nothing-here" , nil ); resp != "nothing here" {
52
- t .Fatalf (resp )
52
+ t .Fatal (resp )
53
53
}
54
54
}
55
55
@@ -80,22 +80,22 @@ func TestStripSlashesInRoute(t *testing.T) {
80
80
defer ts .Close ()
81
81
82
82
if _ , resp := testRequest (t , ts , "GET" , "/hi" , nil ); resp != "hi" {
83
- t .Fatalf (resp )
83
+ t .Fatal (resp )
84
84
}
85
85
if _ , resp := testRequest (t , ts , "GET" , "/hi/" , nil ); resp != "nothing here" {
86
- t .Fatalf (resp )
86
+ t .Fatal (resp )
87
87
}
88
88
if _ , resp := testRequest (t , ts , "GET" , "/accounts/admin" , nil ); resp != "accounts index" {
89
- t .Fatalf (resp )
89
+ t .Fatal (resp )
90
90
}
91
91
if _ , resp := testRequest (t , ts , "GET" , "/accounts/admin/" , nil ); resp != "accounts index" {
92
- t .Fatalf (resp )
92
+ t .Fatal (resp )
93
93
}
94
94
if _ , resp := testRequest (t , ts , "GET" , "/accounts/admin/query" , nil ); resp != "admin" {
95
- t .Fatalf (resp )
95
+ t .Fatal (resp )
96
96
}
97
97
if _ , resp := testRequest (t , ts , "GET" , "/accounts/admin/query/" , nil ); resp != "admin" {
98
- t .Fatalf (resp )
98
+ t .Fatal (resp )
99
99
}
100
100
}
101
101
@@ -125,33 +125,33 @@ func TestRedirectSlashes(t *testing.T) {
125
125
ts := httptest .NewServer (r )
126
126
defer ts .Close ()
127
127
128
- if resp , body := testRequest (t , ts , "GET" , "/" , nil ); body != "root" && resp .StatusCode != 200 {
129
- t .Fatalf (body )
128
+ if resp , body := testRequest (t , ts , "GET" , "/" , nil ); body != "root" || resp .StatusCode != 200 {
129
+ t .Fatal (body , resp . StatusCode )
130
130
}
131
131
132
132
// NOTE: the testRequest client will follow the redirection..
133
- if resp , body := testRequest (t , ts , "GET" , "//" , nil ); body != "root" && resp .StatusCode != 200 {
134
- t .Fatalf (body )
133
+ if resp , body := testRequest (t , ts , "GET" , "//" , nil ); body != "root" || resp .StatusCode != 200 {
134
+ t .Fatal (body , resp . StatusCode )
135
135
}
136
136
137
- if resp , body := testRequest (t , ts , "GET" , "/accounts/admin" , nil ); body != "admin" && resp .StatusCode != 200 {
138
- t .Fatalf (body )
137
+ if resp , body := testRequest (t , ts , "GET" , "/accounts/admin" , nil ); body != "admin" || resp .StatusCode != 200 {
138
+ t .Fatal (body , resp . StatusCode )
139
139
}
140
140
141
141
// NOTE: the testRequest client will follow the redirection..
142
- if resp , body := testRequest (t , ts , "GET" , "/accounts/admin/" , nil ); body != "admin" && resp .StatusCode != 200 {
143
- t .Fatalf (body )
142
+ if resp , body := testRequest (t , ts , "GET" , "/accounts/admin/" , nil ); body != "admin" || resp .StatusCode != 200 {
143
+ t .Fatal (body , resp . StatusCode )
144
144
}
145
145
146
- if resp , body := testRequest (t , ts , "GET" , "/nothing-here" , nil ); body != "nothing here" && resp .StatusCode != 200 {
147
- t .Fatalf (body )
146
+ if resp , body := testRequest (t , ts , "GET" , "/nothing-here" , nil ); body != "nothing here" || resp .StatusCode != 404 {
147
+ t .Fatal (body , resp . StatusCode )
148
148
}
149
149
150
150
// Ensure redirect Location url is correct
151
151
{
152
152
resp , body := testRequestNoRedirect (t , ts , "GET" , "/accounts/someuser/" , nil )
153
153
if resp .StatusCode != 301 {
154
- t .Fatalf (body )
154
+ t .Fatal (body , resp . StatusCode )
155
155
}
156
156
location := resp .Header .Get ("Location" )
157
157
if ! strings .HasPrefix (location , "//" ) || ! strings .HasSuffix (location , "/accounts/someuser" ) {
@@ -163,7 +163,7 @@ func TestRedirectSlashes(t *testing.T) {
163
163
{
164
164
resp , body := testRequestNoRedirect (t , ts , "GET" , "/accounts/someuser/?a=1&b=2" , nil )
165
165
if resp .StatusCode != 301 {
166
- t .Fatalf (body )
166
+ t .Fatal (body , resp . StatusCode )
167
167
}
168
168
location := resp .Header .Get ("Location" )
169
169
if ! strings .HasPrefix (location , "//" ) || ! strings .HasSuffix (location , "/accounts/someuser?a=1&b=2" ) {
@@ -180,8 +180,8 @@ func TestRedirectSlashes(t *testing.T) {
180
180
if u , err := url .Parse (ts .URL ); err != nil && resp .Request .URL .Host != u .Host {
181
181
t .Fatalf ("host should remain the same. got: %q, want: %q" , resp .Request .URL .Host , ts .URL )
182
182
}
183
- if body != "nothing here" && resp .StatusCode != 404 {
184
- t .Fatalf (body )
183
+ if body != "nothing here" || resp .StatusCode != 404 {
184
+ t .Fatal (body , resp . StatusCode )
185
185
}
186
186
}
187
187
}
@@ -192,8 +192,8 @@ func TestRedirectSlashes(t *testing.T) {
192
192
if u , err := url .Parse (ts .URL ); err != nil && resp .Request .URL .Host != u .Host {
193
193
t .Fatalf ("host should remain the same. got: %q, want: %q" , resp .Request .URL .Host , ts .URL )
194
194
}
195
- if body != "nothing here" && resp .StatusCode != 404 {
196
- t .Fatalf (body )
195
+ if body != "nothing here" || resp .StatusCode != 404 {
196
+ t .Fatal (body , resp . StatusCode )
197
197
}
198
198
}
199
199
}
@@ -219,21 +219,21 @@ func TestStripSlashesWithNilContext(t *testing.T) {
219
219
defer ts .Close ()
220
220
221
221
if _ , resp := testRequest (t , ts , "GET" , "/" , nil ); resp != "root" {
222
- t .Fatalf (resp )
222
+ t .Fatal (resp )
223
223
}
224
224
if _ , resp := testRequest (t , ts , "GET" , "//" , nil ); resp != "root" {
225
- t .Fatalf (resp )
225
+ t .Fatal (resp )
226
226
}
227
227
if _ , resp := testRequest (t , ts , "GET" , "/accounts" , nil ); resp != "accounts" {
228
- t .Fatalf (resp )
228
+ t .Fatal (resp )
229
229
}
230
230
if _ , resp := testRequest (t , ts , "GET" , "/accounts/" , nil ); resp != "accounts" {
231
- t .Fatalf (resp )
231
+ t .Fatal (resp )
232
232
}
233
233
if _ , resp := testRequest (t , ts , "GET" , "/accounts/admin" , nil ); resp != "admin" {
234
- t .Fatalf (resp )
234
+ t .Fatal (resp )
235
235
}
236
236
if _ , resp := testRequest (t , ts , "GET" , "/accounts/admin/" , nil ); resp != "admin" {
237
- t .Fatalf (resp )
237
+ t .Fatal (resp )
238
238
}
239
239
}
0 commit comments