Fix grpc test vet warning (#3341)
This fixes the vet warning: the cancel function returned by context.WithTimeout should be called, not discarded, to avoid a context leak. Signed-off-by: Ingo Gottwald <in.gottwald@gmail.com>
This commit is contained in:
parent
575cea4496
commit
fa6718d026
1 changed files with 2 additions and 1 deletions
|
@ -22,7 +22,8 @@ func TestGrpc(t *testing.T) {
|
||||||
}
|
}
|
||||||
defer g.Stop()
|
defer g.Stop()
|
||||||
|
|
||||||
ctx, _ := context.WithTimeout(context.Background(), 5*time.Second)
|
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||||
|
defer cancel()
|
||||||
conn, err := grpc.DialContext(ctx, tcp, grpc.WithInsecure(), grpc.WithBlock())
|
conn, err := grpc.DialContext(ctx, tcp, grpc.WithInsecure(), grpc.WithBlock())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Expected no error but got: %s", err)
|
t.Fatalf("Expected no error but got: %s", err)
|
||||||
|
|
Loading…
Add table
Reference in a new issue