mirror of
https://github.com/astaxie/beego.git
synced 2024-11-21 13:10:56 +00:00
Add test for httplib
This commit is contained in:
parent
9524036aab
commit
d07a1eaa8e
@ -15,6 +15,7 @@
|
||||
package httplib
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
@ -23,6 +24,8 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestResponse(t *testing.T) {
|
||||
@ -284,3 +287,16 @@ func TestHeader(t *testing.T) {
|
||||
}
|
||||
t.Log(str)
|
||||
}
|
||||
|
||||
// TestAddFilter make sure that AddFilters only work for the specific request
|
||||
func TestAddFilter(t *testing.T) {
|
||||
req := Get("http://beego.me")
|
||||
req.AddFilters(func(next Filter) Filter {
|
||||
return func(ctx context.Context, req *BeegoHTTPRequest) (*http.Response, error) {
|
||||
return next(ctx, req)
|
||||
}
|
||||
})
|
||||
|
||||
r := Get("http://beego.me")
|
||||
assert.Equal(t, 1, len(req.setting.FilterChains)-len(r.setting.FilterChains))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user