Files
requests/test/middleware/requestCallback_test.go
gospider ec697ef837 sync
2025-01-10 14:34:01 +08:00

29 lines
611 B
Go

package main
import (
"errors"
"strings"
"testing"
"github.com/gospider007/requests"
)
func TestRequestCallBack(t *testing.T) {
_, err := requests.Get(nil, "https://httpbin.org/anything", requests.RequestOption{
ClientOption: requests.ClientOption{
RequestCallBack: func(ctx *requests.Response) error {
response := ctx.Response()
if response != nil {
if response.ContentLength > 100 {
return errors.New("max length")
}
}
return nil
},
},
})
if !strings.Contains(err.Error(), "max length") {
t.Error("err is not max length")
}
}