|
1 | 1 | /* eslint-disable max-len */
|
2 |
| -import { checkRediStack, REDISTACK_PORT } from 'uiSrc/utils' |
3 |
| -import { RedisDefaultModules } from 'uiSrc/slices/interfaces' |
| 2 | +import { isRediStack } from 'uiSrc/utils' |
4 | 3 |
|
5 | 4 | const unmapWithName = (arr: any[]) => arr.map((item) => ({ name: item }))
|
6 | 5 |
|
7 |
| -const REDISTACK_MODULE_DEFAULT = unmapWithName([ |
8 |
| - RedisDefaultModules.ReJSON, |
9 |
| - RedisDefaultModules.Graph, |
10 |
| - RedisDefaultModules.TimeSeries, |
11 |
| - RedisDefaultModules.Search, |
12 |
| - RedisDefaultModules.Bloom, |
13 |
| -].sort()) |
14 |
| - |
15 |
| -const getOutputCheckRediStackTests: any[] = [ |
16 |
| - [ |
17 |
| - [{ port: REDISTACK_PORT, modules: REDISTACK_MODULE_DEFAULT }, { port: 12000, modules: REDISTACK_MODULE_DEFAULT }], |
18 |
| - [{ port: REDISTACK_PORT, modules: REDISTACK_MODULE_DEFAULT, isRediStack: true }, { port: 12000, modules: REDISTACK_MODULE_DEFAULT, isRediStack: false }] |
19 |
| - ], |
20 |
| - [ |
21 |
| - [{ port: REDISTACK_PORT, modules: REDISTACK_MODULE_DEFAULT }], |
22 |
| - [{ port: REDISTACK_PORT, modules: REDISTACK_MODULE_DEFAULT, isRediStack: true }] |
23 |
| - ], |
24 |
| - [ |
25 |
| - [{ port: REDISTACK_PORT, modules: unmapWithName(['']) }], |
26 |
| - [{ port: REDISTACK_PORT, modules: unmapWithName(['']), isRediStack: false }] |
27 |
| - ], |
28 |
| - [ |
29 |
| - [{ port: REDISTACK_PORT, modules: unmapWithName(['search']) }], |
30 |
| - [{ port: REDISTACK_PORT, modules: unmapWithName(['search']), isRediStack: false }] |
31 |
| - ], |
32 |
| - [ |
33 |
| - [{ port: REDISTACK_PORT, modules: unmapWithName(['bf', 'search', 'timeseries']) }], |
34 |
| - [{ port: REDISTACK_PORT, modules: unmapWithName(['bf', 'search', 'timeseries']), isRediStack: false }] |
35 |
| - ], |
36 |
| - [ |
37 |
| - [{ port: 12000, modules: REDISTACK_MODULE_DEFAULT }], |
38 |
| - [{ port: 12000, modules: REDISTACK_MODULE_DEFAULT, isRediStack: true }] |
39 |
| - ], |
40 |
| - [ |
41 |
| - [{ port: 12000, modules: unmapWithName(['search']) }], |
42 |
| - [{ port: 12000, modules: unmapWithName(['search']), isRediStack: false }] |
43 |
| - ], |
44 |
| - // check searchlight - should be also marked as RediStack |
45 |
| - [ |
46 |
| - [{ port: 12000, modules: unmapWithName(['bf', 'timeseries', 'ReJSON', 'searchlight', 'graph']) }], |
47 |
| - [{ port: 12000, modules: unmapWithName(['bf', 'timeseries', 'ReJSON', 'searchlight', 'graph']), isRediStack: true }] |
48 |
| - ], |
49 |
| - [ |
50 |
| - [{ port: 12000, modules: [] }], |
51 |
| - [{ port: 12000, modules: [], isRediStack: false }] |
52 |
| - ], |
53 |
| - [ |
54 |
| - [{ port: 12000, modules: unmapWithName(['ReJSON']) }], |
55 |
| - [{ port: 12000, modules: unmapWithName(['ReJSON']), isRediStack: false }] |
56 |
| - ], |
57 |
| - [ |
58 |
| - [{ port: 12000, modules: unmapWithName(['bf', 'timeseries', 'ReJSON', 'searchlight', 'graph', 'custom']) }], |
59 |
| - [{ port: 12000, modules: unmapWithName(['bf', 'timeseries', 'ReJSON', 'searchlight', 'graph', 'custom']), isRediStack: false }] |
60 |
| - ], |
| 6 | +const isRediStackTests = [ |
| 7 | + { input: [unmapWithName(['bf', 'timeseries', 'ReJSON', 'searchlight', 'graph', 'custom']), '6.2.6'], expected: false }, |
| 8 | + { input: [unmapWithName(['bf', 'timeseries', 'ReJSON', 'search', 'graph', 'custom']), '6.2.6'], expected: false }, |
| 9 | + { input: [unmapWithName(['bf', 'timeseries', 'ReJSON', 'searchlight', 'graph']), '6.2.6'], expected: true }, |
| 10 | + { input: [unmapWithName(['bf', 'timeseries', 'ReJSON', 'searchlight', 'graph'])], expected: true }, |
| 11 | + { input: [unmapWithName(['bf', 'timeseries', 'ReJSON', 'searchlight', 'graph']), null], expected: true }, |
| 12 | + { input: [unmapWithName(['bf', 'timeseries', 'ReJSON', 'search']), null], expected: false }, |
| 13 | + { input: [unmapWithName(['bf', 'timeseries', 'ReJSON', 'rg', 'search'])], expected: false }, |
| 14 | + { input: [unmapWithName(['bf', 'timeseries', 'ReJSON', 'search', 'graph']), '6.2.6'], expected: true }, |
| 15 | + { input: [unmapWithName(['bf', 'timeseries', 'ReJSON', 'searchlight', 'graph']), '6.2.5'], expected: false }, |
| 16 | + { input: [unmapWithName(['bf', 'timeseries', 'ReJSON', 'search', 'graph']), '6.2.5'], expected: false }, |
| 17 | + { input: [unmapWithName(['bf', 'timeseries', 'ReJSON', 'searchlight', 'graph']), '7.2'], expected: false }, |
| 18 | + { input: [unmapWithName(['bf', 'timeseries', 'ReJSON', 'search', 'graph']), '7.2'], expected: false }, |
| 19 | + { input: [unmapWithName(['bf', 'timeseries', 'ReJSON', 'rg', 'searchlight']), '7.2'], expected: true }, |
| 20 | + { input: [unmapWithName(['bf', 'timeseries', 'ReJSON', 'rg', 'search']), '7.2'], expected: true }, |
| 21 | + { input: [unmapWithName(['bf', 'timeseries', 'ReJSON', 'searchlight']), '7.2'], expected: true }, |
| 22 | + { input: [unmapWithName(['bf', 'timeseries', 'ReJSON', 'search']), '7.2'], expected: true }, |
| 23 | + { input: [unmapWithName(['bf', 'timeseries', 'ReJSON', 'search']), '7.2'], expected: true }, |
| 24 | + { input: [unmapWithName(['bf', 'timeseries', 'ReJSON', 'search', 'custom']), '7.2'], expected: false }, |
| 25 | + { input: [unmapWithName(['bf', 'timeseries', 'ReJSON', 'seasearchlightrch', 'custom']), '7.2'], expected: false }, |
61 | 26 | ]
|
62 | 27 |
|
63 |
| -describe('checkRediStack', () => { |
64 |
| - it.each(getOutputCheckRediStackTests)('for input: %s (reply), should be output: %s', |
65 |
| - (reply, expected) => { |
66 |
| - const result = checkRediStack(reply) |
67 |
| - expect(result).toStrictEqual(expected) |
68 |
| - }) |
| 28 | +describe('isRediStack', () => { |
| 29 | + test.each(isRediStackTests)( |
| 30 | + '%j', |
| 31 | + ({ input, expected }) => { |
| 32 | + // @ts-ignore |
| 33 | + const result = isRediStack(...input) |
| 34 | + expect(result).toEqual(expected) |
| 35 | + } |
| 36 | + ) |
69 | 37 | })
|
0 commit comments