Skip to content

Commit b1ec02d

Browse files
committed
add a test to verify we return standalone connection
1 parent ba805a1 commit b1ec02d

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

redisinsight/api/src/modules/database/providers/database.factory.spec.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,23 @@ describe('DatabaseFactory', () => {
112112

113113
expect(result).toEqual(mockClusterDatabaseWithTlsAuth);
114114
});
115+
it('should create standalone model when cluster database is passed but with standalone flag on', async () => {
116+
mockRedisSentinelUtil.isSentinel.mockResolvedValue(false);
117+
mockRedisClusterUtil.isCluster.mockResolvedValue(true);
118+
119+
const result = await service.createDatabaseModel(mockSessionMetadata, {
120+
...mockClusterDatabaseWithTlsAuth,
121+
forceStandalone: true,
122+
});
123+
124+
expect({
125+
forceStandalone: result.forceStandalone,
126+
connectionType: result.connectionType,
127+
}).toEqual({
128+
forceStandalone: true,
129+
connectionType: ConnectionType.STANDALONE,
130+
});
131+
});
115132
});
116133

117134
describe('createStandaloneDatabaseModel', () => {

redisinsight/api/src/modules/database/providers/database.factory.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export class DatabaseFactory {
7373
database,
7474
client,
7575
);
76-
} else if ((await isCluster(client)) && !database.forceStandalone) {
76+
} else if (!database.forceStandalone && (await isCluster(client))) {
7777
model = await this.createClusterDatabaseModel(
7878
sessionMetadata,
7979
database,

0 commit comments

Comments
 (0)