From 0d178ee53f861ea0daa0adfdd412a027a0a88b77 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Mon, 10 Jun 2024 20:56:01 +0000 Subject: [PATCH] fix tests --- CHANGELOG.md | 1 + node/tests/SharedTests.ts | 38 ++++++++++++++++++-------------------- 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cccb3c3026..57e798bad6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,5 @@ #### Changes +* Node: Added ZUNIONSTORE command ([#1550](https://github.com/aws/glide-for-redis/pull/1550)) * Node: Added ZINTERSTORE command ([#1513](https://github.com/aws/glide-for-redis/pull/1513)) * Python: Added OBJECT ENCODING command ([#1471](https://github.com/aws/glide-for-redis/pull/1471)) * Python: Added OBJECT FREQ command ([#1472](https://github.com/aws/glide-for-redis/pull/1472)) diff --git a/node/tests/SharedTests.ts b/node/tests/SharedTests.ts index be8969c44d..0f8973cc6e 100644 --- a/node/tests/SharedTests.ts +++ b/node/tests/SharedTests.ts @@ -2013,7 +2013,7 @@ export function runBaseTests(config: { config.timeout, ); - // Zunionstore command tests + // ZUnionstore command tests async function zunionstoreWithAggregation(client: BaseClient) { const key1 = "{testKey}:1-" + uuidv4(); const key2 = "{testKey}:2-" + uuidv4(); @@ -2037,7 +2037,7 @@ export function runBaseTests(config: { two: 2.5, three: 3.5, }; - expect(compareMaps(zunionstoreMapMax, expectedMapMax)).toBe(true); + expect(zunionstoreMapMax).toEqual(expectedMapMax); // Union results are aggregated by the MIN score of elements expect(await client.zunionstore(key3, [key1, key2], "MIN")).toEqual(3); @@ -2047,7 +2047,7 @@ export function runBaseTests(config: { two: 2.0, three: 3.5, }; - expect(compareMaps(zunionstoreMapMin, expectedMapMin)).toBe(true); + expect(zunionstoreMapMin).toEqual(expectedMapMin); // Union results are aggregated by the SUM score of elements expect(await client.zunionstore(key3, [key1, key2], "SUM")).toEqual(3); @@ -2057,7 +2057,7 @@ export function runBaseTests(config: { two: 4.5, three: 3.5, }; - expect(compareMaps(zunionstoreMapSum, expectedMapSum)).toBe(true); + expect(zunionstoreMapSum).toEqual(expectedMapSum); } async function zunionstoreBasicTest(client: BaseClient) { @@ -2078,11 +2078,11 @@ export function runBaseTests(config: { expect(await client.zunionstore(key3, [key1, key2])).toEqual(3); const zunionstoreMap = await client.zrangeWithScores(key3, range); const expectedMap = { - one: 2.5, - two: 4.5, - three: 3.5, + one: 3.0, + three: 4.0, + two: 5.0, }; - expect(compareMaps(zunionstoreMap, expectedMap)).toBe(true); + expect(zunionstoreMap).toEqual(expectedMap); } async function zunionstoreWithWeightsAndAggregation(client: BaseClient) { @@ -2119,19 +2119,19 @@ export function runBaseTests(config: { three: 7.0, two: 9.0, }; - expect( - compareMaps(zunionstoreMapMultiplied, expectedMapMultiplied), - ).toBe(true); + expect(zunionstoreMapMultiplied).toEqual(expectedMapMultiplied); } async function zunionstoreEmptyCases(client: BaseClient) { const key1 = "{testKey}:1-" + uuidv4(); const key2 = "{testKey}:2-" + uuidv4(); - const key3 = "{testKey}:2-" + uuidv4(); const range = { start: 0, stop: -1, }; + const membersScores1 = { one: 1.0, two: 2.0 }; + + expect(await client.zadd(key1, membersScores1)).toEqual(2); // Non existing key expect( @@ -2142,7 +2142,7 @@ export function runBaseTests(config: { ).toEqual(2); const zunionstore_map_nonexistingkey = await client.zrangeWithScores( - key3, + key2, range, ); @@ -2150,9 +2150,7 @@ export function runBaseTests(config: { one: 1.0, two: 2.0, }; - expect( - compareMaps(zunionstore_map_nonexistingkey, expectedMapMultiplied), - ).toBe(true); + expect(zunionstore_map_nonexistingkey).toEqual(expectedMapMultiplied); // Empty list check await expect(client.zunionstore("{xyz}", [])).rejects.toThrow(); @@ -2162,10 +2160,10 @@ export function runBaseTests(config: { `zunionstore test_%p`, async (protocol) => { await runTest(async (client: BaseClient) => { - await zunionstoreBasicTest; - await zunionstoreWithAggregation; - await zunionstoreWithWeightsAndAggregation; - await zunionstoreEmptyCases; + await zunionstoreBasicTest(client); + await zunionstoreWithAggregation(client); + await zunionstoreWithWeightsAndAggregation(client); + await zunionstoreEmptyCases(client); }, protocol); }, config.timeout,