Skip to content

Commit 82c6819

Browse files
committed
Merge branch 'v5-search-broken' into cmd-parser-with-commands
2 parents b74e530 + e1b935c commit 82c6819

File tree

10 files changed

+396
-231
lines changed

10 files changed

+396
-231
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
- name: Install Packages
3434
run: npm ci
3535
- name: Build
36-
run: npm run build -- ./packages/client ./packages/test-utils ./packages/bloom ./packages/graph ./packages/json ./packages/search ./packages/time-series ./packages/redis
36+
run: npm run build
3737
- name: Run Tests
3838
run: npm run test -ws --if-present -- --forbid-only --redis-version=${{ matrix.redis-version }}
3939
- name: Upload to Codecov

packages/client/lib/client/index.spec.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -389,11 +389,10 @@ describe('Client', () => {
389389
): Promise<void> {
390390
const onceErrorPromise = once(errorClient, 'error');
391391
await client.sendCommand(['QUIT']);
392-
await onceErrorPromise;
393-
// await Promise.all([
394-
// onceErrorPromise,
395-
// assert.rejects(client.ping(), SocketClosedUnexpectedlyError)
396-
// ]);
392+
await Promise.all([
393+
onceErrorPromise,
394+
assert.rejects(client.ping())
395+
]);
397396
}
398397

399398
testUtils.testWithClient('should reconnect when socket disconnects', async client => {

packages/client/lib/commands/HELLO.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ describe('HELLO', () => {
6464
assert.equal(typeof reply.id, 'number');
6565
assert.equal(reply.mode, 'standalone');
6666
assert.equal(reply.role, 'master');
67-
assert.equal('modules' in reply, true);
67+
assert.ok(reply.modules instanceof Array);
6868
}, {
6969
...GLOBAL.SERVERS.OPEN,
7070
minimumDockerVersion: [6, 2]

packages/client/lib/commands/generic-transformers.ts

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@ export const transformNullableDoubleReply = {
104104
3: undefined as unknown as () => DoubleReply | NullReply
105105
};
106106

107+
export interface Stringable {
108+
toString(): string;
109+
}
110+
107111
export function transformTuplesToMap<T>(
108112
reply: UnwrapReply<ArrayReply<any>>,
109113
func: (elem: any) => T,
@@ -117,42 +121,42 @@ export function transformTuplesToMap<T>(
117121
return message;
118122
}
119123

120-
export function createTransformTuplesReplyFunc(preserve?: any, typeMapping?: TypeMapping) {
121-
return (reply: ArrayReply<BlobStringReply>) => {
122-
return transformTuplesReply(reply, preserve, typeMapping);
124+
export function createTransformTuplesReplyFunc<T extends Stringable>(preserve?: any, typeMapping?: TypeMapping) {
125+
return (reply: ArrayReply<T>) => {
126+
return transformTuplesReply<T>(reply, preserve, typeMapping);
123127
};
124128
}
125129

126-
export function transformTuplesReply(
127-
reply: ArrayReply<BlobStringReply>,
130+
export function transformTuplesReply<T extends Stringable>(
131+
reply: ArrayReply<T>,
128132
preserve?: any,
129133
typeMapping?: TypeMapping
130-
): MapReply<BlobStringReply, BlobStringReply> {
134+
): MapReply<T , T> {
131135
const mapType = typeMapping ? typeMapping[RESP_TYPES.MAP] : undefined;
132136

133137
const inferred = reply as unknown as UnwrapReply<typeof reply>
134138

135139
switch (mapType) {
136140
case Array: {
137-
return reply as unknown as MapReply<BlobStringReply, BlobStringReply>;
141+
return reply as unknown as MapReply<T, T>;
138142
}
139143
case Map: {
140144
const ret = new Map<string, BlobStringReply>;
141145

142146
for (let i = 0; i < inferred.length; i += 2) {
143-
ret.set(inferred[i].toString(), inferred[i + 1]);
147+
ret.set(inferred[i].toString(), inferred[i + 1] as any);
144148
}
145149

146-
return ret as unknown as MapReply<BlobStringReply, BlobStringReply>;;
150+
return ret as unknown as MapReply<T, T>;;
147151
}
148152
default: {
149153
const ret: Record<string, BlobStringReply> = Object.create(null);
150154

151155
for (let i = 0; i < inferred.length; i += 2) {
152-
ret[inferred[i].toString()] = inferred[i + 1];
156+
ret[inferred[i].toString()] = inferred[i + 1] as any;
153157
}
154158

155-
return ret as unknown as MapReply<BlobStringReply, BlobStringReply>;;
159+
return ret as unknown as MapReply<T, T>;;
156160
}
157161
}
158162
}

packages/client/lib/sentinel/commands/SENTINEL_MASTER.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default {
77
parser.push('SENTINEL', 'MASTER', dbname);
88
},
99
transformReply: {
10-
2: transformTuplesReply,
10+
2: transformTuplesReply<BlobStringReply>,
1111
3: undefined as unknown as () => MapReply<BlobStringReply, BlobStringReply>
1212
}
1313
} as const satisfies Command;

packages/search/lib/commands/INFO.spec.ts

Lines changed: 90 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { strict as assert } from 'node:assert';
22
import testUtils, { GLOBAL } from '../test-utils';
3-
import INFO from './INFO';
3+
import INFO, { InfoReply } from './INFO';
44
import { SCHEMA_FIELD_TYPE } from './CREATE';
55
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
66

@@ -16,7 +16,94 @@ describe('INFO', () => {
1616
await client.ft.create('index', {
1717
field: SCHEMA_FIELD_TYPE.TEXT
1818
});
19-
// just test that it doesn't throw an error
20-
await client.ft.info('index');
19+
const ret = await client.ft.info('index');
20+
assert.deepEqual(ret.stopWords, undefined);
21+
assert.deepEqual(
22+
ret,
23+
{
24+
indexName: 'index',
25+
indexOptions: [],
26+
indexDefinition: Object.create(null, {
27+
default_score: {
28+
value: '1',
29+
configurable: true,
30+
enumerable: true
31+
},
32+
key_type: {
33+
value: 'HASH',
34+
configurable: true,
35+
enumerable: true
36+
},
37+
prefixes: {
38+
value: [''],
39+
configurable: true,
40+
enumerable: true
41+
}
42+
}),
43+
attributes: [Object.create(null, {
44+
identifier: {
45+
value: 'field',
46+
configurable: true,
47+
enumerable: true
48+
},
49+
attribute: {
50+
value: 'field',
51+
configurable: true,
52+
enumerable: true
53+
},
54+
type: {
55+
value: 'TEXT',
56+
configurable: true,
57+
enumerable: true
58+
},
59+
WEIGHT: {
60+
value: '1',
61+
configurable: true,
62+
enumerable: true
63+
}
64+
})],
65+
numDocs: 0,
66+
maxDocId: 0,
67+
numTerms: 0,
68+
numRecords: 0,
69+
invertedSzMb: 0,
70+
vectorIndexSzMb: 0,
71+
totalInvertedIndexBlocks: 0,
72+
offsetVectorsSzMb: 0,
73+
docTableSizeMb: 0,
74+
sortableValuesSizeMb: 0,
75+
keyTableSizeMb: 0,
76+
recordsPerDocAvg: NaN,
77+
bytesPerRecordAvg: NaN,
78+
cleaning: 0,
79+
offsetsPerTermAvg: NaN,
80+
offsetBitsPerRecordAvg: NaN,
81+
geoshapeSizeMb: 0,
82+
hashIndexingFailures: 0,
83+
indexing: 0,
84+
percentIndexed: 1,
85+
numberOfUses: 1,
86+
tagOverheadSizeMb: 0,
87+
textOverheadSizeMb: 0,
88+
totalIndexMemorySizeMb: 0,
89+
totalIndexingTime: 0,
90+
gcStats: {
91+
bytesCollected: 0,
92+
totalMsRun: 0,
93+
totalCycles: 0,
94+
averageCycleTimeMs: NaN,
95+
lastRunTimeMs: 0,
96+
gcNumericTreesMissed: 0,
97+
gcBlocksDenied: 0
98+
},
99+
cursorStats: {
100+
globalIdle: 0,
101+
globalTotal: 0,
102+
indexCapacity: 128,
103+
indexTotal: 0
104+
},
105+
}
106+
);
107+
21108
}, GLOBAL.SERVERS.OPEN);
22109
});

0 commit comments

Comments
 (0)