Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Ubuntu committed Jun 10, 2024
1 parent 7109e26 commit 0d178ee
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 20 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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))
Expand Down
38 changes: 18 additions & 20 deletions node/tests/SharedTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2013,7 +2013,7 @@ export function runBaseTests<Context>(config: {
config.timeout,
);

// Zunionstore command tests
// ZUnionstore command tests
async function zunionstoreWithAggregation(client: BaseClient) {
const key1 = "{testKey}:1-" + uuidv4();
const key2 = "{testKey}:2-" + uuidv4();
Expand All @@ -2037,7 +2037,7 @@ export function runBaseTests<Context>(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);
Expand All @@ -2047,7 +2047,7 @@ export function runBaseTests<Context>(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);
Expand All @@ -2057,7 +2057,7 @@ export function runBaseTests<Context>(config: {
two: 4.5,
three: 3.5,
};
expect(compareMaps(zunionstoreMapSum, expectedMapSum)).toBe(true);
expect(zunionstoreMapSum).toEqual(expectedMapSum);
}

async function zunionstoreBasicTest(client: BaseClient) {
Expand All @@ -2078,11 +2078,11 @@ export function runBaseTests<Context>(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) {
Expand Down Expand Up @@ -2119,19 +2119,19 @@ export function runBaseTests<Context>(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(
Expand All @@ -2142,17 +2142,15 @@ export function runBaseTests<Context>(config: {
).toEqual(2);

const zunionstore_map_nonexistingkey = await client.zrangeWithScores(
key3,
key2,
range,
);

const expectedMapMultiplied = {
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();
Expand All @@ -2162,10 +2160,10 @@ export function runBaseTests<Context>(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,
Expand Down

0 comments on commit 0d178ee

Please sign in to comment.