diff --git a/clientv3/integration/lease_test.go b/clientv3/integration/lease_test.go index 96e7d632641..bcb3cf3ba8a 100644 --- a/clientv3/integration/lease_test.go +++ b/clientv3/integration/lease_test.go @@ -102,7 +102,6 @@ func TestLeaseKeepAlive(t *testing.T) { defer clus.Terminate(t) lapi := clientv3.NewLease(clus.RandClient()) - defer lapi.Close() resp, err := lapi.Create(context.Background(), 10) if err != nil { @@ -114,10 +113,21 @@ func TestLeaseKeepAlive(t *testing.T) { t.Errorf("failed to keepalive lease %v", kerr) } - kresp := <-rc + kresp, ok := <-rc + if !ok { + t.Errorf("chan is closed, want not closed") + } + if kresp.ID != resp.ID { t.Errorf("ID = %x, want %x", kresp.ID, resp.ID) } + + lapi.Close() + + _, ok = <-rc + if ok { + t.Errorf("chan is not closed, want lease Close() closes chan") + } } // TODO: add a client that can connect to all the members of cluster via unix sock.