Skip to content

Commit d7d6492

Browse files
committed
feedback
1 parent 172a5dd commit d7d6492

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

go/vt/topo/zk2topo/zk_conn_test.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"context"
2121
"testing"
2222

23+
"github.com/stretchr/testify/require"
2324
"github.com/z-division/go-zookeeper/zk"
2425

2526
"vitess.io/vitess/go/testfiles"
@@ -31,6 +32,8 @@ func TestZkConnClosedOnDisconnect(t *testing.T) {
3132
defer zkd.Teardown()
3233

3334
conn := Connect(serverAddr)
35+
defer conn.Close()
36+
3437
_, _, err := conn.Get(context.Background(), "/")
3538
if err != nil {
3639
t.Fatalf("Get() failed: %v", err)
@@ -42,7 +45,7 @@ func TestZkConnClosedOnDisconnect(t *testing.T) {
4245

4346
oldConn := conn.conn
4447

45-
// simulate a disconnect
48+
// force a disconnect
4649
zkd.Shutdown()
4750
zkd.Start()
4851

@@ -54,11 +57,9 @@ func TestZkConnClosedOnDisconnect(t *testing.T) {
5457

5558
// Check that old connection is closed
5659
_, _, err = oldConn.Get("/")
57-
if err == nil {
58-
t.Fatalf("Get() should have failed: %v", err)
59-
}
60+
require.ErrorContains(t, err, "zookeeper is closing")
6061

6162
if oldConn.State() != zk.StateDisconnected {
62-
t.Fatalf("Connection not closed: %v", oldConn.State())
63+
t.Fatalf("Connection is not in disconnected state: %v", oldConn.State())
6364
}
6465
}

0 commit comments

Comments
 (0)