@@ -87,11 +87,21 @@ describe('RedisConnectionFactory', () => {
87
87
process . nextTick ( ( ) => mockClient . emit ( 'ready' ) ) ;
88
88
} ) ;
89
89
90
- it ( 'should fail to create standalone connection' , ( done ) => {
90
+ it ( 'should successfully create standalone client even with error event emited' , ( done ) => {
91
+ service . createStandaloneConnection ( mockClientMetadata , mockDatabaseWithTlsAuth , { useRetry : true } )
92
+ . then ( checkClient ( done , mockClient ) ) ;
93
+ process . nextTick ( ( ) => mockClient . emit ( 'error' , mockError ) ) ;
94
+ process . nextTick ( ( ) => mockClient . emit ( 'ready' ) ) ;
95
+ } ) ;
96
+
97
+ it ( 'should fail to create standalone with last error' , ( done ) => {
91
98
service . createStandaloneConnection ( mockClientMetadata , mockDatabaseWithTlsAuth , { } )
92
99
. catch ( checkError ( done ) ) ;
93
100
101
+ process . nextTick ( ( ) => mockClient . emit ( 'error' , new Error ( '1' ) ) ) ;
102
+ process . nextTick ( ( ) => mockClient . emit ( 'error' , new Error ( '2' ) ) ) ;
94
103
process . nextTick ( ( ) => mockClient . emit ( 'error' , mockError ) ) ;
104
+ process . nextTick ( ( ) => mockClient . emit ( 'end' ) ) ;
95
105
} ) ;
96
106
97
107
it ( 'should handle sync error during standalone client creation' , ( done ) => {
@@ -113,11 +123,22 @@ describe('RedisConnectionFactory', () => {
113
123
process . nextTick ( ( ) => mockCluster . emit ( 'ready' ) ) ;
114
124
} ) ;
115
125
116
- it ( 'should fail to create cluster connection' , ( done ) => {
126
+ it ( 'should successfully create cluster client and not fail even when error emited' , ( done ) => {
127
+ service . createClusterConnection ( mockClientMetadata , mockClusterDatabaseWithTlsAuth , { } )
128
+ . then ( checkClient ( done , mockCluster ) ) ;
129
+
130
+ process . nextTick ( ( ) => mockCluster . emit ( 'error' , mockError ) ) ;
131
+ process . nextTick ( ( ) => mockCluster . emit ( 'ready' ) ) ;
132
+ } ) ;
133
+
134
+ it ( 'should fail to create cluster connection with last error' , ( done ) => {
117
135
service . createClusterConnection ( mockClientMetadata , mockClusterDatabaseWithTlsAuth , { } )
118
136
. catch ( checkError ( done ) ) ;
119
137
138
+ process . nextTick ( ( ) => mockCluster . emit ( 'error' , new Error ( '1' ) ) ) ;
139
+ process . nextTick ( ( ) => mockCluster . emit ( 'error' , new Error ( '2' ) ) ) ;
120
140
process . nextTick ( ( ) => mockCluster . emit ( 'error' , mockError ) ) ;
141
+ process . nextTick ( ( ) => mockCluster . emit ( 'end' ) ) ;
121
142
} ) ;
122
143
123
144
it ( 'should handle sync error during cluster client creation' , ( done ) => {
@@ -138,11 +159,22 @@ describe('RedisConnectionFactory', () => {
138
159
process . nextTick ( ( ) => mockClient . emit ( 'ready' ) ) ;
139
160
} ) ;
140
161
141
- it ( 'should fail to create sentinel connection' , ( done ) => {
162
+ it ( 'should successfully create sentinel client and not fail even when error emited' , ( done ) => {
163
+ service . createSentinelConnection ( mockClientMetadata , mockSentinelDatabaseWithTlsAuth , { useRetry : true } )
164
+ . then ( checkClient ( done , mockClient ) ) ;
165
+
166
+ process . nextTick ( ( ) => mockClient . emit ( 'error' , mockError ) ) ;
167
+ process . nextTick ( ( ) => mockClient . emit ( 'ready' ) ) ;
168
+ } ) ;
169
+
170
+ it ( 'should fail to create sentinel connection with last error' , ( done ) => {
142
171
service . createSentinelConnection ( mockClientMetadata , mockSentinelDatabaseWithTlsAuth , { } )
143
172
. catch ( checkError ( done ) ) ;
144
173
174
+ process . nextTick ( ( ) => mockClient . emit ( 'error' , new Error ( '1' ) ) ) ;
175
+ process . nextTick ( ( ) => mockClient . emit ( 'error' , new Error ( '2' ) ) ) ;
145
176
process . nextTick ( ( ) => mockClient . emit ( 'error' , mockError ) ) ;
177
+ process . nextTick ( ( ) => mockClient . emit ( 'end' ) ) ;
146
178
} ) ;
147
179
148
180
it ( 'should handle sync error during sentinel client creation' , ( done ) => {
0 commit comments