Merge tag 'tags/v1.11.0'
This commit is contained in:
+7
-7
@@ -29,7 +29,7 @@ type testStruct struct {
|
||||
}
|
||||
|
||||
func (t *testStruct) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||
assert.Equal(t.T, "POST", req.Method)
|
||||
assert.Equal(t.T, http.MethodPost, req.Method)
|
||||
assert.Equal(t.T, "/path", req.URL.Path)
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
fmt.Fprint(w, "hello")
|
||||
@@ -39,17 +39,17 @@ func TestWrap(t *testing.T) {
|
||||
router := New()
|
||||
router.POST("/path", WrapH(&testStruct{t}))
|
||||
router.GET("/path2", WrapF(func(w http.ResponseWriter, req *http.Request) {
|
||||
assert.Equal(t, "GET", req.Method)
|
||||
assert.Equal(t, http.MethodGet, req.Method)
|
||||
assert.Equal(t, "/path2", req.URL.Path)
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
fmt.Fprint(w, "hola!")
|
||||
}))
|
||||
|
||||
w := PerformRequest(router, "POST", "/path")
|
||||
w := PerformRequest(router, http.MethodPost, "/path")
|
||||
assert.Equal(t, http.StatusInternalServerError, w.Code)
|
||||
assert.Equal(t, "hello", w.Body.String())
|
||||
|
||||
w = PerformRequest(router, "GET", "/path2")
|
||||
w = PerformRequest(router, http.MethodGet, "/path2")
|
||||
assert.Equal(t, http.StatusBadRequest, w.Code)
|
||||
assert.Equal(t, "hola!", w.Body.String())
|
||||
}
|
||||
@@ -94,7 +94,7 @@ func somefunction() {
|
||||
}
|
||||
|
||||
func TestJoinPaths(t *testing.T) {
|
||||
assert.Equal(t, "", joinPaths("", ""))
|
||||
assert.Empty(t, joinPaths("", ""))
|
||||
assert.Equal(t, "/", joinPaths("", "/"))
|
||||
assert.Equal(t, "/a", joinPaths("/a", ""))
|
||||
assert.Equal(t, "/a/", joinPaths("/a/", ""))
|
||||
@@ -119,13 +119,13 @@ func TestBindMiddleware(t *testing.T) {
|
||||
called = true
|
||||
value = c.MustGet(BindKey).(*bindTestStruct)
|
||||
})
|
||||
PerformRequest(router, "GET", "/?foo=hola&bar=10")
|
||||
PerformRequest(router, http.MethodGet, "/?foo=hola&bar=10")
|
||||
assert.True(t, called)
|
||||
assert.Equal(t, "hola", value.Foo)
|
||||
assert.Equal(t, 10, value.Bar)
|
||||
|
||||
called = false
|
||||
PerformRequest(router, "GET", "/?foo=hola&bar=1")
|
||||
PerformRequest(router, http.MethodGet, "/?foo=hola&bar=1")
|
||||
assert.False(t, called)
|
||||
|
||||
assert.Panics(t, func() {
|
||||
|
||||
Reference in New Issue
Block a user