Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions pkg/commands/json_set.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@ import { afterAll } from "https://deno.land/[email protected]/testing/bdd.ts";

import { JsonSetCommand } from "./json_set.ts";
import { JsonGetCommand } from "./json_get.ts";
import { assertEquals } from "https://deno.land/[email protected]/testing/asserts.ts";
import {
assert,
assertEquals,
} from "https://deno.land/[email protected]/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");
Expand All @@ -32,15 +35,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<any[]>([key, "$"]).exec(client);

assert(res3 !== null);
assertEquals(res3.length, 1);
assertEquals(res3[0]?.f1?.a, 3);
assertEquals(res3[0]?.f2?.a, 3);
});
6 changes: 5 additions & 1 deletion pkg/commands/zrange.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,11 @@ 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,
);
Expand Down
2 changes: 1 addition & 1 deletion pkg/pipeline.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down