Skip to content

Commit e6fe071

Browse files
committed
fix tests
1 parent 1cbbbda commit e6fe071

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

x/mongo/driver/topology/connection_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ func TestConnection(t *testing.T) {
6363
t.Run("connect", func(t *testing.T) {
6464
t.Run("dialer error", func(t *testing.T) {
6565
err := errors.New("dialer error")
66-
var want error = ConnectionError{Wrapped: err, init: true}
67-
conn := newConnection(address.Address(""), WithDialer(func(Dialer) Dialer {
66+
var want error = ConnectionError{Wrapped: err, init: true, message: "failed to connect to testaddr"}
67+
conn := newConnection(address.Address("testaddr"), WithDialer(func(Dialer) Dialer {
6868
return DialerFunc(func(context.Context, string, string) (net.Conn, error) { return nil, err })
6969
}))
7070
got := conn.connect(context.Background())

x/mongo/driver/topology/pool_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,7 @@ func TestPool_checkOut(t *testing.T) {
471471

472472
dialErr := errors.New("create new connection error")
473473
p := newPool(poolConfig{
474+
Address: "testaddr",
474475
ConnectTimeout: defaultConnectionTimeout,
475476
}, WithDialer(func(Dialer) Dialer {
476477
return DialerFunc(func(context.Context, string, string) (net.Conn, error) {
@@ -481,7 +482,7 @@ func TestPool_checkOut(t *testing.T) {
481482
require.NoError(t, err)
482483

483484
_, err = p.checkOut(context.Background())
484-
var want error = ConnectionError{Wrapped: dialErr, init: true}
485+
var want error = ConnectionError{Wrapped: dialErr, init: true, message: "failed to connect to testaddr:27017"}
485486
assert.Equalf(t, want, err, "should return error from calling checkOut()")
486487
// If a connection initialization error occurs during checkOut, removing and closing the
487488
// failed connection both happen asynchronously with the checkOut. Wait for up to 2s for

x/mongo/driver/topology/server_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ func TestServer(t *testing.T) {
376376
}
377377

378378
authErr := ConnectionError{Wrapped: &auth.Error{}, init: true}
379-
netErr := ConnectionError{Wrapped: &net.AddrError{}, init: true}
379+
netErr := ConnectionError{Wrapped: &net.AddrError{}, init: true, message: "failed to connect to localhost:27017"}
380380
for _, tt := range serverTestTable {
381381
t.Run(tt.name, func(t *testing.T) {
382382
var returnConnectionError bool

0 commit comments

Comments
 (0)