Skip to content

Commit 1e70a33

Browse files
author
Artem
committed
fix unit tests. some of tests/files were disabled
1 parent a667d22 commit 1e70a33

31 files changed

+2685
-2629
lines changed

redisinsight/api/src/__mocks__/autodiscovery-tools.ts

Lines changed: 0 additions & 61 deletions
This file was deleted.

redisinsight/api/src/__mocks__/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@ export * from './errors';
77
// export * from './redis-databases';
88
export * from './redis-info';
99
export * from './app-settings';
10-
// export * from './autodiscovery-tools';
1110
export * from './analytics';
1211
export * from './profiler';
1312
export * from './user';
1413
export * from './databases';
1514
export * from './autodiscovery';
1615
export * from './redis';
1716
export * from './server';
17+
export * from './redis-enterprise';
18+
export * from './redis-sentinel';
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import { RedisEnterpriseDatabase } from 'src/modules/redis-enterprise/dto/cluster.dto';
2+
import { RedisEnterpriseDatabaseStatus } from 'src/modules/redis-enterprise/models/redis-enterprise-database';
3+
import { GetRedisCloudSubscriptionResponse, RedisCloudDatabase } from 'src/modules/redis-enterprise/dto/cloud.dto';
4+
import { RedisCloudSubscriptionStatus } from 'src/modules/redis-enterprise/models/redis-cloud-subscriptions';
5+
6+
export const mockRedisEnterpriseDatabaseDto: RedisEnterpriseDatabase = {
7+
uid: 1,
8+
address: '172.17.0.2',
9+
dnsName: 'redis-12000.clus.local',
10+
modules: [],
11+
name: 'db',
12+
options: {},
13+
port: 12000,
14+
status: RedisEnterpriseDatabaseStatus.Active,
15+
tls: false,
16+
password: null,
17+
};
18+
19+
export const mockRedisCloudSubscriptionDto: GetRedisCloudSubscriptionResponse = {
20+
id: 1,
21+
name: 'Basic subscription example',
22+
numberOfDatabases: 1,
23+
provider: 'AWS',
24+
region: 'us-east-1',
25+
status: RedisCloudSubscriptionStatus.Active,
26+
};
27+
28+
export const mockRedisCloudDatabaseDto: RedisCloudDatabase = {
29+
databaseId: 51166493,
30+
subscriptionId: 1,
31+
modules: [],
32+
name: 'Database',
33+
options: {},
34+
publicEndpoint: 'redis.us-east-1-1.rlrcp.com:12315',
35+
sslClientAuthentication: false,
36+
status: RedisEnterpriseDatabaseStatus.Active,
37+
};
38+
39+
export const mockRedisEnterpriseAnalytics = jest.fn(() => ({
40+
sendGetREClusterDbsSucceedEvent: jest.fn(),
41+
sendGetREClusterDbsFailedEvent: jest.fn(),
42+
sendGetRECloudSubsSucceedEvent: jest.fn(),
43+
sendGetRECloudSubsFailedEvent: jest.fn(),
44+
sendGetRECloudDbsSucceedEvent: jest.fn(),
45+
sendGetRECloudDbsFailedEvent: jest.fn(),
46+
}));
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { SentinelMaster, SentinelMasterStatus } from 'src/modules/redis-sentinel/models/sentinel-master';
2+
3+
export const mockSentinelMasterDto: SentinelMaster = {
4+
name: 'mymaster',
5+
host: '127.0.0.1',
6+
port: 6379,
7+
numberOfSlaves: 1,
8+
status: SentinelMasterStatus.Active,
9+
nodes: [{
10+
host: '127.0.0.1',
11+
port: 26379,
12+
}],
13+
};
14+
15+
export const mockRedisSentinelAnalytics = jest.fn(() => ({
16+
sendGetSentinelMastersSucceedEvent: jest.fn(),
17+
sendGetSentinelMastersFailedEvent: jest.fn(),
18+
}));

redisinsight/api/src/__mocks__/redis.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,24 @@ export const mockIORedisClient = {
1919
},
2020
};
2121

22+
export const mockIORedisCluster = {
23+
...Object.create(IORedis.Cluster.prototype),
24+
isCluster: true,
25+
sendCommand: jest.fn(),
26+
info: jest.fn(),
27+
monitor: jest.fn(),
28+
disconnect: jest.fn(),
29+
duplicate: jest.fn(),
30+
call: jest.fn(),
31+
subscribe: jest.fn(),
32+
psubscribe: jest.fn(),
33+
unsubscribe: jest.fn(),
34+
punsubscribe: jest.fn(),
35+
publish: jest.fn(),
36+
status: 'ready',
37+
nodes: jest.fn().mockReturnValue([mockIORedisClient, mockIORedisClient]),
38+
};
39+
2240
export const mockRedisService = jest.fn(() => ({
2341
createStandaloneClient: jest.fn(),
2442
}));

redisinsight/api/src/modules/autodiscovery/utils/autodiscovery.util.spec.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import * as events from 'events';
99
import * as stream from 'stream';
1010
import { ChildProcess } from 'child_process';
1111
import * as autodiscoveryUtility from './autodiscovery.util';
12-
import { getRunningProcesses, getTCPEndpoints } from './autodiscovery.util';
1312

1413
jest.mock('os', () => ({
1514
...jest.requireActual('os') as object,

0 commit comments

Comments
 (0)