Skip to content

Commit 9a2d3cf

Browse files
committed
remove redundant tests
1 parent 0eeb452 commit 9a2d3cf

11 files changed

Lines changed: 20 additions & 353 deletions

File tree

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

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -18,27 +18,4 @@ describe('CLUSTER INFO', () => {
1818
'string'
1919
);
2020
}, GLOBAL.CLUSTERS.OPEN);
21-
22-
testUtils.testWithCluster('structural assertion - RESP2 bulk string format', async cluster => {
23-
const client = await cluster.nodeClient(cluster.masters[0]);
24-
const reply = await client.clusterInfo();
25-
26-
// Assert it's a string (RESP2 bulk string)
27-
assert.equal(typeof reply, 'string');
28-
29-
// Assert the response follows the <field>:<value> CRLF-separated format
30-
// Expected fields according to Redis docs
31-
assert.ok(reply.includes('cluster_state:'), 'should contain cluster_state field');
32-
assert.ok(reply.includes('cluster_slots_assigned:'), 'should contain cluster_slots_assigned field');
33-
assert.ok(reply.includes('cluster_known_nodes:'), 'should contain cluster_known_nodes field');
34-
35-
// Assert CRLF line endings (this is the key structural element)
36-
const lines = reply.split('\r\n').filter(line => line.length > 0);
37-
assert.ok(lines.length > 0, 'should have multiple lines separated by CRLF');
38-
39-
// Each line should follow <field>:<value> format
40-
for (const line of lines) {
41-
assert.ok(line.includes(':'), `line "${line}" should contain colon separator`);
42-
}
43-
}, GLOBAL.CLUSTERS.OPEN);
4421
});

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

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,6 @@ describe('CONFIG GET', () => {
2929
}
3030
}, GLOBAL.SERVERS.OPEN);
3131

32-
testUtils.testWithClient('client.configGet with specific parameter pins RESP2 structure', async client => {
33-
const reply = await client.configGet('maxmemory');
34-
// RESP2 returns object (transformed from array of tuples)
35-
// This structural assertion would break if RESP3 returns a Map
36-
assert.deepEqual(
37-
Object.keys(reply).sort(),
38-
['maxmemory']
39-
);
40-
assert.equal(typeof reply.maxmemory, 'string');
41-
}, GLOBAL.SERVERS.OPEN);
42-
4332
testUtils.testWithClient('client.configSet.getSearchConfigSettingTest | Redis >= 8', async client => {
4433
assert.ok(
4534
await client.configGet('search-timeout'),

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

Lines changed: 0 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -178,81 +178,4 @@ describe('HOTKEYS GET', () => {
178178
...GLOBAL.SERVERS.OPEN,
179179
minimumDockerVersion: [8, 6]
180180
});
181-
182-
testUtils.testWithClient('client.hotkeysGet returns correct RESP2 structure', async client => {
183-
// Clean up any existing state first
184-
await client.hotkeysStop();
185-
await client.hotkeysReset();
186-
187-
// Start tracking with both CPU and NET metrics
188-
await client.hotkeysStart({
189-
METRICS: { count: 2, CPU: true, NET: true }
190-
});
191-
192-
// Perform some operations to generate hotkey data
193-
await client.set('structureTestKey', 'value');
194-
await client.get('structureTestKey');
195-
196-
// GET should return data with the expected RESP2 structure
197-
const reply = await client.hotkeysGet();
198-
assert.ok(reply !== null, 'Expected reply to not be null');
199-
200-
// Verify the structure is a plain object (not a Map or Array)
201-
// This assertion pins down that RESP2 returns an array-of-pairs that gets transformed to an object
202-
// If RESP3 sends a Map instead and transformReply isn't updated, this will break
203-
assert.ok(typeof reply === 'object' && reply !== null && !Array.isArray(reply) && !(reply instanceof Map));
204-
205-
// Verify all required fields are present with correct types
206-
// This structural assertion would break if the RESP2 array-of-pairs format changed to RESP3 map
207-
const requiredFields = {
208-
trackingActive: 'number',
209-
sampleRatio: 'number',
210-
selectedSlots: 'array',
211-
allCommandsAllSlotsUs: 'number',
212-
netBytesAllCommandsAllSlots: 'number',
213-
collectionStartTimeUnixMs: 'number',
214-
collectionDurationMs: 'number',
215-
totalCpuTimeSysMs: 'number',
216-
totalCpuTimeUserMs: 'number',
217-
totalNetBytes: 'number'
218-
};
219-
220-
for (const [field, expectedType] of Object.entries(requiredFields)) {
221-
assert.ok(Object.prototype.hasOwnProperty.call(reply, field), `Field ${field} must be present`);
222-
if (expectedType === 'array') {
223-
assert.ok(Array.isArray((reply as any)[field]), `Field ${field} must be an array`);
224-
} else {
225-
assert.equal(typeof (reply as any)[field], expectedType, `Field ${field} must be ${expectedType}`);
226-
}
227-
}
228-
229-
// Verify metric arrays structure if present
230-
if (reply.byCpuTimeUs) {
231-
assert.ok(Array.isArray(reply.byCpuTimeUs), 'byCpuTimeUs must be an array');
232-
reply.byCpuTimeUs.forEach(entry => {
233-
// Each entry must be a plain object with 'key' and 'value' properties
234-
// This pins down the RESP2 flat array [k1,v1,k2,v2] -> [{key:k1,value:v1},{key:k2,value:v2}] structure
235-
assert.deepEqual(Object.keys(entry).sort(), ['key', 'value']);
236-
assert.equal(typeof entry.key, 'string');
237-
assert.equal(typeof entry.value, 'number');
238-
});
239-
}
240-
241-
if (reply.byNetBytes) {
242-
assert.ok(Array.isArray(reply.byNetBytes), 'byNetBytes must be an array');
243-
reply.byNetBytes.forEach(entry => {
244-
assert.deepEqual(Object.keys(entry).sort(), ['key', 'value']);
245-
assert.equal(typeof entry.key, 'string');
246-
assert.equal(typeof entry.value, 'number');
247-
});
248-
}
249-
250-
// Clean up
251-
await client.hotkeysStop();
252-
await client.hotkeysReset();
253-
}, {
254-
...GLOBAL.SERVERS.OPEN,
255-
minimumDockerVersion: [8, 6]
256-
});
257181
});
258-

packages/client/lib/commands/HOTKEYS_GET.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ export default {
175175
if (reply === null) return null;
176176
return transformHotkeysGetReply(reply);
177177
},
178-
3: undefined as unknown as () => ReplyUnion
178+
3: undefined as unknown as () => HotkeysGetReply
179179
},
180180
unstableResp3: true
181181
} as const satisfies Command;

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

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,4 @@ describe('LATENCY DOCTOR', () => {
1717
'string'
1818
);
1919
}, GLOBAL.SERVERS.OPEN);
20-
21-
testUtils.testWithClient('client.latencyDoctor returns plain bulk string (RESP2)', async client => {
22-
const reply = await client.latencyDoctor();
23-
24-
// Must be a string (bulk string in RESP2, not verbatim string object)
25-
assert.equal(typeof reply, 'string');
26-
27-
// Must be a plain primitive string, not an object
28-
assert.ok(reply.constructor === String || typeof reply === 'string');
29-
30-
// Should not be a structured object (would indicate verbatim string transformation)
31-
assert.ok(!(reply && typeof reply === 'object' && 'format' in reply));
32-
}, GLOBAL.SERVERS.OPEN);
3320
});

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

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -45,19 +45,4 @@ describe('MEMORY STATS', () => {
4545
}
4646
}, GLOBAL.SERVERS.OPEN);
4747

48-
testUtils.testWithClient('client.memoryStats - RESP2 returns plain object structure', async client => {
49-
const memoryStats = await client.memoryStats();
50-
51-
// Structural assertions to ensure RESP2 returns a plain object (not Array, not Map)
52-
assert.ok(typeof memoryStats === 'object', 'memoryStats should be an object');
53-
assert.ok(memoryStats !== null, 'memoryStats should not be null');
54-
assert.ok(!Array.isArray(memoryStats), 'memoryStats should not be an Array');
55-
assert.ok(!(memoryStats instanceof Map), 'memoryStats should not be a Map');
56-
assert.ok(memoryStats.constructor === Object, 'memoryStats should be a plain Object');
57-
58-
// Verify it has the expected keys as own properties
59-
assert.ok(memoryStats.hasOwnProperty('peak.allocated'), 'should have peak.allocated');
60-
assert.ok(memoryStats.hasOwnProperty('total.allocated'), 'should have total.allocated');
61-
assert.ok(memoryStats.hasOwnProperty('dataset.percentage'), 'should have dataset.percentage');
62-
}, GLOBAL.SERVERS.OPEN);
6348
});

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

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -25,36 +25,4 @@ describe('VEMB', () => {
2525
cluster: { ...GLOBAL.CLUSTERS.OPEN, minimumDockerVersion: [8, 0] }
2626
});
2727

28-
testUtils.testAll('vEmb returns exact array structure (RESP2)', async client => {
29-
await client.vAdd('key', [1.0, 2.0, 3.0], 'element');
30-
31-
const result = await client.vEmb('key', 'element');
32-
assert.ok(Array.isArray(result));
33-
assert.equal(result.length, 3);
34-
// Assert each element is a number (not string, not object)
35-
result.forEach(val => {
36-
assert.equal(typeof val, 'number');
37-
assert.ok(!isNaN(val));
38-
});
39-
// Verify exact structure - any change from array to map/object would break this
40-
assert.deepStrictEqual(Object.keys(result), ['0', '1', '2']);
41-
}, {
42-
client: { ...GLOBAL.SERVERS.OPEN, minimumDockerVersion: [8, 0] },
43-
cluster: { ...GLOBAL.CLUSTERS.OPEN, minimumDockerVersion: [8, 0] }
44-
});
45-
46-
testUtils.testWithClient('vEmb with RESP3', async client => {
47-
await client.vAdd('resp3-key', [1.5, 2.5, 3.5, 4.5], 'resp3-element');
48-
49-
const result = await client.vEmb('resp3-key', 'resp3-element');
50-
assert.ok(Array.isArray(result));
51-
assert.equal(result.length, 4);
52-
assert.equal(typeof result[0], 'number');
53-
}, {
54-
...GLOBAL.SERVERS.OPEN,
55-
clientOptions: {
56-
RESP: 3
57-
},
58-
minimumDockerVersion: [8, 0]
59-
});
6028
});

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

Lines changed: 19 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -18,71 +18,30 @@ describe('VINFO', () => {
1818

1919
const result = await client.vInfo('key');
2020
assert.ok(typeof result === 'object' && result !== null);
21-
22-
assert.equal(result['vector-dim'], 3);
23-
assert.equal(result['size'], 1);
24-
assert.ok('quant-type' in result);
25-
assert.ok('hnsw-m' in result);
26-
assert.ok('projection-input-dim' in result);
27-
assert.ok('max-level' in result);
28-
assert.ok('attributes-count' in result);
29-
assert.ok('vset-uid' in result);
30-
assert.ok('hnsw-max-node-uid' in result);
31-
}, {
32-
client: { ...GLOBAL.SERVERS.OPEN, minimumDockerVersion: [8, 0] },
33-
cluster: { ...GLOBAL.CLUSTERS.OPEN, minimumDockerVersion: [8, 0] }
34-
});
35-
36-
testUtils.testWithClient('vInfo structural assertion (RESP2)', async client => {
37-
await client.vAdd('key', [1.0, 2.0, 3.0], 'element');
38-
39-
const result = await client.vInfo('key');
40-
41-
// Structural assertion: ensure all expected keys exist and have correct types
42-
assert.ok(typeof result === 'object' && result !== null);
43-
assert.ok('quant-type' in result);
44-
assert.equal(typeof result['quant-type'], 'string');
45-
assert.ok('vector-dim' in result);
46-
assert.equal(typeof result['vector-dim'], 'number');
47-
assert.equal(result['vector-dim'], 3);
48-
assert.ok('size' in result);
49-
assert.equal(typeof result['size'], 'number');
50-
assert.equal(result['size'], 1);
51-
assert.ok('max-level' in result);
52-
assert.equal(typeof result['max-level'], 'number');
53-
assert.ok('vset-uid' in result);
54-
assert.equal(typeof result['vset-uid'], 'number');
55-
assert.ok('hnsw-max-node-uid' in result);
56-
assert.equal(typeof result['hnsw-max-node-uid'], 'number');
57-
58-
// Verify it's a plain object (RESP2 transformation result), not an array or Map
59-
assert.equal(Object.getPrototypeOf(result), null);
6021
assert.equal(Array.isArray(result), false);
61-
}, {
62-
...GLOBAL.SERVERS.OPEN,
63-
minimumDockerVersion: [8, 0]
64-
});
22+
assert.equal(result instanceof Map, false);
23+
24+
const expectedKeys = [
25+
'quant-type',
26+
'hnsw-m',
27+
'vector-dim',
28+
'projection-input-dim',
29+
'size',
30+
'max-level',
31+
'attributes-count',
32+
'vset-uid',
33+
'hnsw-max-node-uid'
34+
];
6535

66-
testUtils.testWithClient('vInfo with RESP3', async client => {
67-
await client.vAdd('resp3-key', [1.0, 2.0, 3.0], 'resp3-element');
68-
69-
const result = await client.vInfo('resp3-key');
70-
assert.ok(typeof result === 'object' && result !== null);
36+
assert.deepEqual(
37+
Object.keys(result).sort(),
38+
expectedKeys.sort()
39+
);
7140

7241
assert.equal(result['vector-dim'], 3);
7342
assert.equal(result['size'], 1);
74-
assert.ok('quant-type' in result);
75-
assert.ok('hnsw-m' in result);
76-
assert.ok('projection-input-dim' in result);
77-
assert.ok('max-level' in result);
78-
assert.ok('attributes-count' in result);
79-
assert.ok('vset-uid' in result);
80-
assert.ok('hnsw-max-node-uid' in result);
8143
}, {
82-
...GLOBAL.SERVERS.OPEN,
83-
clientOptions: {
84-
RESP: 3
85-
},
86-
minimumDockerVersion: [8, 0]
44+
client: { ...GLOBAL.SERVERS.OPEN, minimumDockerVersion: [8, 0] },
45+
cluster: { ...GLOBAL.CLUSTERS.OPEN, minimumDockerVersion: [8, 0] }
8746
});
8847
});

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

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -24,37 +24,4 @@ describe('VLINKS', () => {
2424
client: { ...GLOBAL.SERVERS.OPEN, minimumDockerVersion: [8, 0] },
2525
cluster: { ...GLOBAL.CLUSTERS.OPEN, minimumDockerVersion: [8, 0] }
2626
});
27-
28-
testUtils.testWithClient('vLinks RESP2 response structure', async client => {
29-
await client.vAdd('key', [1.0, 2.0, 3.0], 'element1');
30-
await client.vAdd('key', [1.1, 2.1, 3.1], 'element2');
31-
await client.vAdd('key', [1.2, 2.2, 3.2], 'element3');
32-
33-
const result = await client.vLinks('key', 'element1');
34-
assert.ok(Array.isArray(result));
35-
for (const layer of result) {
36-
assert.ok(Array.isArray(layer));
37-
for (const element of layer) {
38-
assert.equal(typeof element, 'string');
39-
}
40-
}
41-
}, {
42-
...GLOBAL.SERVERS.OPEN,
43-
minimumDockerVersion: [8, 0]
44-
});
45-
46-
testUtils.testWithClient('vLinks with RESP3', async client => {
47-
await client.vAdd('resp3-key', [1.0, 2.0, 3.0], 'element1');
48-
await client.vAdd('resp3-key', [1.1, 2.1, 3.1], 'element2');
49-
50-
const result = await client.vLinks('resp3-key', 'element1');
51-
assert.ok(Array.isArray(result));
52-
assert.ok(result.length)
53-
}, {
54-
...GLOBAL.SERVERS.OPEN,
55-
clientOptions: {
56-
RESP: 3
57-
},
58-
minimumDockerVersion: [8, 0]
59-
});
6027
});

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

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -35,37 +35,4 @@ describe('VSETATTR', () => {
3535
client: { ...GLOBAL.SERVERS.OPEN, minimumDockerVersion: [8, 0] },
3636
cluster: { ...GLOBAL.CLUSTERS.OPEN, minimumDockerVersion: [8, 0] }
3737
});
38-
39-
testUtils.testWithClient('vSetAttr - RESP2 returns boolean type', async client => {
40-
await client.vAdd('key', [1.0, 2.0, 3.0], 'element');
41-
42-
const result = await client.vSetAttr('key', 'element', { name: 'test', value: 42 });
43-
44-
// RESP2 returns integer (0/1) but should be transformed to boolean
45-
assert.strictEqual(typeof result, 'boolean');
46-
assert.strictEqual(result, true);
47-
}, {
48-
...GLOBAL.SERVERS.OPEN,
49-
minimumDockerVersion: [8, 0]
50-
});
51-
52-
testUtils.testWithClient('vSetAttr with RESP3 - returns boolean', async client => {
53-
await client.vAdd('resp3-key', [1.0, 2.0, 3.0], 'resp3-element');
54-
55-
const result = await client.vSetAttr('resp3-key', 'resp3-element', {
56-
name: 'test-item',
57-
category: 'electronics',
58-
price: 99.99
59-
});
60-
61-
// RESP3 returns boolean instead of number
62-
assert.equal(typeof result, 'boolean');
63-
assert.equal(result, true);
64-
}, {
65-
...GLOBAL.SERVERS.OPEN,
66-
clientOptions: {
67-
RESP: 3
68-
},
69-
minimumDockerVersion: [8, 0]
70-
});
7138
});

0 commit comments

Comments
 (0)