Skip to content

Commit

Permalink
clientv3/integration: test on lease close
Browse files Browse the repository at this point in the history
  • Loading branch information
xiang90 committed Feb 2, 2016
1 parent 3a7a3ee commit 68e81c7
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions clientv3/integration/lease_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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.
Expand Down

0 comments on commit 68e81c7

Please sign in to comment.