Skip to content

Commit

Permalink
fix: ut
Browse files Browse the repository at this point in the history
  • Loading branch information
welkeyever committed Aug 21, 2024
1 parent febd58a commit ea83ff8
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pkg/app/client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -408,15 +408,20 @@ func TestClientReadTimeout(t *testing.T) {
opt.Addr = "localhost:10008"
engine := route.NewEngine(opt)

mut := &sync.Mutex{}

engine.GET("/", func(c context.Context, ctx *app.RequestContext) {
mut.Lock()
if timeout {
mut.Unlock()
time.Sleep(time.Minute)
} else {
timeout = true
mut.Unlock()
}
})
go engine.Run()
time.Sleep(time.Millisecond * 500)
time.Sleep(time.Second * 1)

c := &http1.HostClient{
ClientOptions: &http1.ClientOptions{
Expand Down Expand Up @@ -453,6 +458,7 @@ func TestClientReadTimeout(t *testing.T) {
req.SetConnectionClose()

if err := c.Do(context.Background(), req, res); !errors.Is(err, errs.ErrTimeout) {
assert.NotNil(t, err)
if !strings.Contains(err.Error(), "timeout") {
t.Errorf("expected ErrTimeout got %#v", err)
}
Expand Down

0 comments on commit ea83ff8

Please sign in to comment.