Skip to content

Commit a796238

Browse files
moeryomenkoelithrar
authored andcommitted
replace rr.HeaderMap by rr.Header() (#443)
1 parent 797e653 commit a796238

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

middleware_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ func TestMiddlewareExecution(t *testing.T) {
151151
// Test handler-only call
152152
router.ServeHTTP(rw, req)
153153

154-
if bytes.Compare(rw.Body.Bytes(), handlerStr) != 0 {
154+
if !bytes.Equal(rw.Body.Bytes(), handlerStr) {
155155
t.Fatal("Handler response is not what it should be")
156156
}
157157

@@ -166,7 +166,7 @@ func TestMiddlewareExecution(t *testing.T) {
166166
})
167167

168168
router.ServeHTTP(rw, req)
169-
if bytes.Compare(rw.Body.Bytes(), append(mwStr, handlerStr...)) != 0 {
169+
if !bytes.Equal(rw.Body.Bytes(), append(mwStr, handlerStr...)) {
170170
t.Fatal("Middleware + handler response is not what it should be")
171171
}
172172
}
@@ -368,7 +368,7 @@ func TestCORSMethodMiddleware(t *testing.T) {
368368
t.Errorf("Expected body '%s', found '%s'", tt.response, rr.Body.String())
369369
}
370370

371-
allowedMethods := rr.HeaderMap.Get("Access-Control-Allow-Methods")
371+
allowedMethods := rr.Header().Get("Access-Control-Allow-Methods")
372372

373373
if allowedMethods != tt.expectedAllowedMethods {
374374
t.Errorf("Expected Access-Control-Allow-Methods '%s', found '%s'", tt.expectedAllowedMethods, allowedMethods)

mux_test.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1123,10 +1123,7 @@ func TestSchemes(t *testing.T) {
11231123

11241124
func TestMatcherFunc(t *testing.T) {
11251125
m := func(r *http.Request, m *RouteMatch) bool {
1126-
if r.URL.Host == "aaa.bbb.ccc" {
1127-
return true
1128-
}
1129-
return false
1126+
return r.URL.Host == "aaa.bbb.ccc"
11301127
}
11311128

11321129
tests := []routeTest{

0 commit comments

Comments
 (0)