mirror of
https://github.com/astaxie/beego.git
synced 2024-11-21 17:00:57 +00:00
Add test for httplib
This commit is contained in:
parent
9524036aab
commit
d07a1eaa8e
@ -15,6 +15,7 @@
|
|||||||
package httplib
|
package httplib
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net"
|
"net"
|
||||||
@ -23,6 +24,8 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestResponse(t *testing.T) {
|
func TestResponse(t *testing.T) {
|
||||||
@ -284,3 +287,16 @@ func TestHeader(t *testing.T) {
|
|||||||
}
|
}
|
||||||
t.Log(str)
|
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