From ab220487a0a3a32c943c84e7023ab6438ad02ac5 Mon Sep 17 00:00:00 2001 From: Andreas Thomas Date: Thu, 30 Mar 2023 18:47:20 +0200 Subject: [PATCH 1/4] test: add argument to unlink --- pkg/pipeline.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/pipeline.test.ts b/pkg/pipeline.test.ts index bcb9aa31..8f6ad3b2 100644 --- a/pkg/pipeline.test.ts +++ b/pkg/pipeline.test.ts @@ -195,7 +195,7 @@ Deno.test("use all the things", async (t) => { .touch(newKey()) .ttl(newKey()) .type(newKey()) - .unlink() + .unlink(newKey()) .zadd(newKey(), { score: 0, member: "member" }) .zcard(newKey()) .scriptExists(scriptHash) From 567aa0aeaf511f02b988b99976e47a9dc1048730 Mon Sep 17 00:00:00 2001 From: Andreas Thomas Date: Thu, 30 Mar 2023 20:58:57 +0200 Subject: [PATCH 2/4] test: update a few tests to be compatible with stock redis --- pkg/commands/json_set.test.ts | 19 +++++++++++-------- pkg/commands/zrange.test.ts | 2 +- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/pkg/commands/json_set.test.ts b/pkg/commands/json_set.test.ts index 8aa0c28a..450526f0 100644 --- a/pkg/commands/json_set.test.ts +++ b/pkg/commands/json_set.test.ts @@ -3,14 +3,14 @@ import { afterAll } from "https://deno.land/std@0.177.0/testing/bdd.ts"; import { JsonSetCommand } from "./json_set.ts"; import { JsonGetCommand } from "./json_get.ts"; -import { assertEquals } from "https://deno.land/std@0.177.0/testing/asserts.ts"; +import { assert, assertArrayIncludes, assertEquals, assertFalse } from "https://deno.land/std@0.177.0/testing/asserts.ts"; const client = newHttpClient(); const { newKey, cleanup } = keygen(); afterAll(cleanup); -Deno.test("replcae an existing value", async () => { +Deno.test("replace an existing value", async () => { const key = newKey(); const res1 = await new JsonSetCommand([key, "$", { a: 2 }]).exec(client); assertEquals(res1, "OK"); @@ -32,15 +32,18 @@ Deno.test("add a new value", async () => { Deno.test("update multi-paths", async () => { const key = newKey(); - const res1 = await new JsonSetCommand([key, "$", { + const data = { f1: { a: 1 }, f2: { a: 2 }, - }]).exec(client); + } + const res1 = await new JsonSetCommand([key, "$", data]).exec(client); assertEquals(res1, "OK"); const res2 = await new JsonSetCommand([key, "$..a", 3]).exec(client); assertEquals(res2, "OK"); - const res3 = await new JsonGetCommand([key, "$"]).exec(client); - // TODO: should be [{ f1: { a: 3 }, f2: { a: 3 } }] - // I reported this to mehmet - assertEquals(res3, [{ f1: { a: 3 }, f2: { a: 3 }, a: 3 }]); + const res3 = await new JsonGetCommand([key, "$"]).exec(client); + + assert(res3 !== null) + assertEquals(res3.length, 1) + assertEquals(res3[0]?.f1?.a, 3) + assertEquals(res3[0]?.f2?.a, 3) }); diff --git a/pkg/commands/zrange.test.ts b/pkg/commands/zrange.test.ts index ae2182e1..ffaa903e 100644 --- a/pkg/commands/zrange.test.ts +++ b/pkg/commands/zrange.test.ts @@ -167,7 +167,7 @@ Deno.test("limit", async (t) => { ]).exec(client); } - const res = await new ZRangeCommand([key, 0, 7, { offset: 0, count: 2 }]) + const res = await new ZRangeCommand([key, 0, 7, { byScore: true, offset: 0, count: 2 }]) .exec( client, ); From 906d444d83052b10093dd8697fa92c1ad1cdbb74 Mon Sep 17 00:00:00 2001 From: Andreas Thomas Date: Thu, 30 Mar 2023 21:17:26 +0200 Subject: [PATCH 3/4] style: fmt --- pkg/commands/json_set.test.ts | 17 +++++++++++------ pkg/commands/zrange.test.ts | 6 +++++- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/pkg/commands/json_set.test.ts b/pkg/commands/json_set.test.ts index 450526f0..64c2287b 100644 --- a/pkg/commands/json_set.test.ts +++ b/pkg/commands/json_set.test.ts @@ -3,7 +3,12 @@ import { afterAll } from "https://deno.land/std@0.177.0/testing/bdd.ts"; import { JsonSetCommand } from "./json_set.ts"; import { JsonGetCommand } from "./json_get.ts"; -import { assert, assertArrayIncludes, assertEquals, assertFalse } from "https://deno.land/std@0.177.0/testing/asserts.ts"; +import { + assert, + assertArrayIncludes, + assertEquals, + assertFalse, +} from "https://deno.land/std@0.177.0/testing/asserts.ts"; const client = newHttpClient(); @@ -35,15 +40,15 @@ Deno.test("update multi-paths", async () => { const data = { f1: { a: 1 }, f2: { a: 2 }, - } + }; const res1 = await new JsonSetCommand([key, "$", data]).exec(client); assertEquals(res1, "OK"); const res2 = await new JsonSetCommand([key, "$..a", 3]).exec(client); assertEquals(res2, "OK"); const res3 = await new JsonGetCommand([key, "$"]).exec(client); - assert(res3 !== null) - assertEquals(res3.length, 1) - assertEquals(res3[0]?.f1?.a, 3) - assertEquals(res3[0]?.f2?.a, 3) + assert(res3 !== null); + assertEquals(res3.length, 1); + assertEquals(res3[0]?.f1?.a, 3); + assertEquals(res3[0]?.f2?.a, 3); }); diff --git a/pkg/commands/zrange.test.ts b/pkg/commands/zrange.test.ts index ffaa903e..c3fdab44 100644 --- a/pkg/commands/zrange.test.ts +++ b/pkg/commands/zrange.test.ts @@ -167,7 +167,11 @@ Deno.test("limit", async (t) => { ]).exec(client); } - const res = await new ZRangeCommand([key, 0, 7, { byScore: true, offset: 0, count: 2 }]) + const res = await new ZRangeCommand([key, 0, 7, { + byScore: true, + offset: 0, + count: 2, + }]) .exec( client, ); From 7e912ccad61eda26f06ce81041049f7014602516 Mon Sep 17 00:00:00 2001 From: Andreas Thomas Date: Thu, 30 Mar 2023 21:21:55 +0200 Subject: [PATCH 4/4] style: fmt --- pkg/commands/json_set.test.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/pkg/commands/json_set.test.ts b/pkg/commands/json_set.test.ts index 64c2287b..032a3abf 100644 --- a/pkg/commands/json_set.test.ts +++ b/pkg/commands/json_set.test.ts @@ -5,9 +5,7 @@ import { JsonSetCommand } from "./json_set.ts"; import { JsonGetCommand } from "./json_get.ts"; import { assert, - assertArrayIncludes, assertEquals, - assertFalse, } from "https://deno.land/std@0.177.0/testing/asserts.ts"; const client = newHttpClient();