@@ -44,6 +44,16 @@ describe('DirectConnectionProvider', () => {
44
44
} ) ;
45
45
} ) ;
46
46
47
+ it ( 'returns an initialized connection' , done => {
48
+ const pool = newPool ( ) ;
49
+ const connectionProvider = newDirectConnectionProvider ( 'localhost:123' , pool ) ;
50
+
51
+ connectionProvider . acquireConnection ( READ ) . then ( connection => {
52
+ expect ( connection . initialized ) . toBeTruthy ( ) ;
53
+ done ( ) ;
54
+ } ) ;
55
+ } ) ;
56
+
47
57
} ) ;
48
58
49
59
describe ( 'LoadBalancer' , ( ) => {
@@ -1049,6 +1059,26 @@ describe('LoadBalancer', () => {
1049
1059
} ) ;
1050
1060
} ) ;
1051
1061
1062
+ it ( 'returns an initialized connection' , done => {
1063
+ const pool = newPool ( ) ;
1064
+ const loadBalancer = newLoadBalancer (
1065
+ [ 'server-1' , 'server-2' ] ,
1066
+ [ 'server-3' , 'server-4' ] ,
1067
+ [ 'server-5' , 'server-6' ] ,
1068
+ pool
1069
+ ) ;
1070
+
1071
+ loadBalancer . acquireConnection ( READ ) . then ( connection => {
1072
+ expect ( connection . initialized ) . toBeTruthy ( ) ;
1073
+
1074
+ loadBalancer . acquireConnection ( WRITE ) . then ( connection => {
1075
+ expect ( connection . initialized ) . toBeTruthy ( ) ;
1076
+
1077
+ done ( ) ;
1078
+ } ) ;
1079
+ } ) ;
1080
+ } ) ;
1081
+
1052
1082
} ) ;
1053
1083
1054
1084
function newDirectConnectionProvider ( address , pool ) {
@@ -1126,13 +1156,15 @@ class FakeConnection {
1126
1156
constructor ( address , release ) {
1127
1157
this . address = address ;
1128
1158
this . release = release ;
1159
+ this . initialized = false ;
1129
1160
}
1130
1161
1131
1162
static create ( address , release ) {
1132
1163
return new FakeConnection ( address , release ) ;
1133
1164
}
1134
1165
1135
1166
initializationCompleted ( ) {
1167
+ this . initialized = true ;
1136
1168
return Promise . resolve ( this ) ;
1137
1169
}
1138
1170
}
0 commit comments