Skip to content

Commit 39741c6

Browse files
author
Artem
committed
fix UTests
1 parent e2b9aac commit 39741c6

File tree

1 file changed

+35
-3
lines changed

1 file changed

+35
-3
lines changed

redisinsight/api/src/modules/redis/redis-connection.factory.spec.ts

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,21 @@ describe('RedisConnectionFactory', () => {
8787
process.nextTick(() => mockClient.emit('ready'));
8888
});
8989

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) => {
9198
service.createStandaloneConnection(mockClientMetadata, mockDatabaseWithTlsAuth, {})
9299
.catch(checkError(done));
93100

101+
process.nextTick(() => mockClient.emit('error', new Error('1')));
102+
process.nextTick(() => mockClient.emit('error', new Error('2')));
94103
process.nextTick(() => mockClient.emit('error', mockError));
104+
process.nextTick(() => mockClient.emit('end'));
95105
});
96106

97107
it('should handle sync error during standalone client creation', (done) => {
@@ -113,11 +123,22 @@ describe('RedisConnectionFactory', () => {
113123
process.nextTick(() => mockCluster.emit('ready'));
114124
});
115125

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) => {
117135
service.createClusterConnection(mockClientMetadata, mockClusterDatabaseWithTlsAuth, {})
118136
.catch(checkError(done));
119137

138+
process.nextTick(() => mockCluster.emit('error', new Error('1')));
139+
process.nextTick(() => mockCluster.emit('error', new Error('2')));
120140
process.nextTick(() => mockCluster.emit('error', mockError));
141+
process.nextTick(() => mockCluster.emit('end'));
121142
});
122143

123144
it('should handle sync error during cluster client creation', (done) => {
@@ -138,11 +159,22 @@ describe('RedisConnectionFactory', () => {
138159
process.nextTick(() => mockClient.emit('ready'));
139160
});
140161

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) => {
142171
service.createSentinelConnection(mockClientMetadata, mockSentinelDatabaseWithTlsAuth, {})
143172
.catch(checkError(done));
144173

174+
process.nextTick(() => mockClient.emit('error', new Error('1')));
175+
process.nextTick(() => mockClient.emit('error', new Error('2')));
145176
process.nextTick(() => mockClient.emit('error', mockError));
177+
process.nextTick(() => mockClient.emit('end'));
146178
});
147179

148180
it('should handle sync error during sentinel client creation', (done) => {

0 commit comments

Comments
 (0)