Skip to content

Commit 0f7e330

Browse files
committed
Delete the useless isAlive test case
1 parent 456a1fd commit 0f7e330

File tree

1 file changed

+0
-82
lines changed

1 file changed

+0
-82
lines changed

x/mongo/driver/topology/connection_test.go

Lines changed: 0 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1161,85 +1161,3 @@ func TestConnectionError(t *testing.T) {
11611161
assert.ErrorContains(t, err, "client timed out waiting for server response")
11621162
})
11631163
}
1164-
1165-
func TestConnection_IsAlive(t *testing.T) {
1166-
t.Parallel()
1167-
1168-
t.Run("uninitialized", func(t *testing.T) {
1169-
t.Parallel()
1170-
1171-
conn := newConnection("")
1172-
assert.False(t,
1173-
conn.isAlive(),
1174-
"expected isAlive for an uninitialized connection to always return false")
1175-
})
1176-
1177-
t.Run("connection open", func(t *testing.T) {
1178-
t.Parallel()
1179-
1180-
cleanup := make(chan struct{})
1181-
defer close(cleanup)
1182-
addr := bootstrapConnections(t, 1, func(nc net.Conn) {
1183-
// Keep the connection open until the end of the test.
1184-
<-cleanup
1185-
_ = nc.Close()
1186-
})
1187-
1188-
conn := newConnection(address.Address(addr.String()))
1189-
err := conn.connect(context.Background())
1190-
require.NoError(t, err)
1191-
1192-
conn.idleStart.Store(time.Now().Add(-11 * time.Second))
1193-
assert.True(t,
1194-
conn.isAlive(),
1195-
"expected isAlive for an open connection to return true")
1196-
})
1197-
1198-
t.Run("connection closed", func(t *testing.T) {
1199-
t.Parallel()
1200-
1201-
conns := make(chan net.Conn)
1202-
addr := bootstrapConnections(t, 1, func(nc net.Conn) {
1203-
conns <- nc
1204-
})
1205-
1206-
conn := newConnection(address.Address(addr.String()))
1207-
err := conn.connect(context.Background())
1208-
require.NoError(t, err)
1209-
1210-
// Close the connection before calling isAlive.
1211-
nc := <-conns
1212-
err = nc.Close()
1213-
require.NoError(t, err)
1214-
1215-
conn.idleStart.Store(time.Now().Add(-11 * time.Second))
1216-
assert.False(t,
1217-
conn.isAlive(),
1218-
"expected isAlive for a closed connection to return false")
1219-
})
1220-
1221-
t.Run("connection reads data", func(t *testing.T) {
1222-
t.Parallel()
1223-
1224-
cleanup := make(chan struct{})
1225-
defer close(cleanup)
1226-
addr := bootstrapConnections(t, 1, func(nc net.Conn) {
1227-
// Write some data to the connection before calling isAlive.
1228-
_, err := nc.Write([]byte{5, 0, 0, 0, 0})
1229-
require.NoError(t, err)
1230-
1231-
// Keep the connection open until the end of the test.
1232-
<-cleanup
1233-
_ = nc.Close()
1234-
})
1235-
1236-
conn := newConnection(address.Address(addr.String()))
1237-
err := conn.connect(context.Background())
1238-
require.NoError(t, err)
1239-
1240-
conn.idleStart.Store(time.Now().Add(-11 * time.Second))
1241-
assert.False(t,
1242-
conn.isAlive(),
1243-
"expected isAlive for an open connection that reads data to return false")
1244-
})
1245-
}

0 commit comments

Comments
 (0)