Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitee0ee70

Browse files
committed
Fix context cancel for HTTP requests
1 parent1a48bea commitee0ee70

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

‎coderd/coderdtest/coderdtest.go‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"database/sql"
66
"io"
7+
"net"
78
"net/http/httptest"
89
"net/url"
910
"os"
@@ -59,7 +60,13 @@ func New(t *testing.T) *codersdk.Client {
5960
Database:db,
6061
Pubsub:pubsub,
6162
})
62-
srv:=httptest.NewServer(handler)
63+
srv:=httptest.NewUnstartedServer(handler)
64+
srv.Config.BaseContext=func(_ net.Listener) context.Context {
65+
ctx,cancelFunc:=context.WithCancel(context.Background())
66+
t.Cleanup(cancelFunc)
67+
returnctx
68+
}
69+
srv.Start()
6370
serverURL,err:=url.Parse(srv.URL)
6471
require.NoError(t,err)
6572
t.Cleanup(srv.Close)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp