mirror of
https://github.com/sourcegraph/jsonrpc2.git
synced 2026-06-16 04:04:56 +02:00
Use t.Cleanup instead of defer in Golang code tests
This commit is contained in:
parent
96c4efab7e
commit
01ce4c18a2
1 changed files with 4 additions and 4 deletions
|
|
@ -121,7 +121,7 @@ func TestClientServer(t *testing.T) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal("Listen:", err)
|
t.Fatal("Listen:", err)
|
||||||
}
|
}
|
||||||
defer func() {
|
t.Cleanup(func() {
|
||||||
if lis == nil {
|
if lis == nil {
|
||||||
return // already closed
|
return // already closed
|
||||||
}
|
}
|
||||||
|
|
@ -130,7 +130,7 @@ func TestClientServer(t *testing.T) {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
})
|
||||||
|
|
||||||
ha := testHandlerA{t: t}
|
ha := testHandlerA{t: t}
|
||||||
go func() {
|
go func() {
|
||||||
|
|
@ -184,11 +184,11 @@ func TestClientServer(t *testing.T) {
|
||||||
func testClientServer(ctx context.Context, t *testing.T, stream jsonrpc2.ObjectStream) {
|
func testClientServer(ctx context.Context, t *testing.T, stream jsonrpc2.ObjectStream) {
|
||||||
hb := testHandlerB{t: t}
|
hb := testHandlerB{t: t}
|
||||||
cc := jsonrpc2.NewConn(ctx, stream, &hb)
|
cc := jsonrpc2.NewConn(ctx, stream, &hb)
|
||||||
defer func() {
|
t.Cleanup(func() {
|
||||||
if err := cc.Close(); err != nil {
|
if err := cc.Close(); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
}()
|
})
|
||||||
|
|
||||||
// Simple
|
// Simple
|
||||||
const n = 100
|
const n = 100
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue