diff --git a/node/src/BaseClient.ts b/node/src/BaseClient.ts index 1c31078305..2bfb9a3bbd 100644 --- a/node/src/BaseClient.ts +++ b/node/src/BaseClient.ts @@ -5523,7 +5523,7 @@ export class BaseClient { * ``` */ public async xinfoGroups( - key: string, + key: GlideString, options?: DecoderOption, ): Promise[]> { return this.createWritePromise< diff --git a/node/src/Commands.ts b/node/src/Commands.ts index fea676c01a..811504301c 100644 --- a/node/src/Commands.ts +++ b/node/src/Commands.ts @@ -2694,7 +2694,7 @@ export function createXInfoStream( } /** @internal */ -export function createXInfoGroups(key: string): command_request.Command { +export function createXInfoGroups(key: GlideString): command_request.Command { return createCommand(RequestType.XInfoGroups, [key]); } diff --git a/node/src/Transaction.ts b/node/src/Transaction.ts index 4a3fe802d4..485d7f06d0 100644 --- a/node/src/Transaction.ts +++ b/node/src/Transaction.ts @@ -1252,7 +1252,7 @@ export class BaseTransaction> { * Command Response - the number of the removed elements. * If `key` does not exist, 0 is returned. */ - public lrem(key: GlideString, count: number, element: string): T { + public lrem(key: GlideString, count: number, element: GlideString): T { return this.addAndReturn(createLRem(key, count, element)); } @@ -2651,7 +2651,7 @@ export class BaseTransaction> { * attributes of a consumer group for the stream at `key`. * The response comes in format `GlideRecord[]`, see {@link GlideRecord}. */ - public xinfoGroups(key: string): T { + public xinfoGroups(key: GlideString): T { return this.addAndReturn(createXInfoGroups(key)); } diff --git a/node/tests/GlideClient.test.ts b/node/tests/GlideClient.test.ts index 4e3a31d195..e97b1ea608 100644 --- a/node/tests/GlideClient.test.ts +++ b/node/tests/GlideClient.test.ts @@ -34,9 +34,8 @@ import { convertStringArrayToBuffer, createLongRunningLuaScript, createLuaLibWithLongRunningFunction, - DumpAndRestureTest, + DumpAndRestoreTest, encodableTransactionTest, - encodedTransactionTest, flushAndCloseClient, generateLuaLibCode, getClientConfigurationOption, @@ -219,42 +218,40 @@ describe("GlideClient", () => { }, ); - it.each([ProtocolVersion.RESP2, ProtocolVersion.RESP3])( - `can send transactions_%p`, - async (protocol) => { - client = await GlideClient.createClient( - getClientConfigurationOption(cluster.getAddresses(), protocol), - ); - const transaction = new Transaction(); - const expectedRes = await transactionTest( - transaction, - cluster.getVersion(), - ); - transaction.select(0); - const result = await client.exec(transaction); - expectedRes.push(["select(0)", "OK"]); - - validateTransactionResponse(result, expectedRes); - client.close(); - }, - ); - - it.each([ProtocolVersion.RESP2, ProtocolVersion.RESP3])( - `can get Bytes decoded transactions_%p`, - async (protocol) => { - client = await GlideClient.createClient( - getClientConfigurationOption(cluster.getAddresses(), protocol), + describe.each([ProtocolVersion.RESP2, ProtocolVersion.RESP3])( + "Protocol is RESP2 = %s", + (protocol) => { + describe.each([Decoder.String, Decoder.Bytes])( + "Decoder String = %s", + (decoder) => { + it( + "can send transactions", + async () => { + client = await GlideClient.createClient( + getClientConfigurationOption( + cluster.getAddresses(), + protocol, + ), + ); + const transaction = new Transaction(); + const expectedRes = await transactionTest( + transaction, + cluster.getVersion(), + decoder, + ); + transaction.select(0); + const result = await client.exec(transaction, { + decoder: Decoder.String, + }); + expectedRes.push(["select(0)", "OK"]); + + validateTransactionResponse(result, expectedRes); + client.close(); + }, + TIMEOUT, + ); + }, ); - const transaction = new Transaction(); - const expectedRes = await encodedTransactionTest(transaction); - transaction.select(0); - const result = await client.exec(transaction, { - decoder: Decoder.Bytes, - }); - expectedRes.push(["select(0)", "OK"]); - - validateTransactionResponse(result, expectedRes); - client.close(); }, ); @@ -265,7 +262,7 @@ describe("GlideClient", () => { getClientConfigurationOption(cluster.getAddresses(), protocol), ); const bytesTransaction = new Transaction(); - const expectedBytesRes = await DumpAndRestureTest( + const expectedBytesRes = await DumpAndRestoreTest( bytesTransaction, Buffer.from("value"), ); @@ -278,7 +275,7 @@ describe("GlideClient", () => { validateTransactionResponse(result, expectedBytesRes); const stringTransaction = new Transaction(); - await DumpAndRestureTest(stringTransaction, "value"); + await DumpAndRestoreTest(stringTransaction, "value"); stringTransaction.select(0); // Since DUMP gets binary results, we cannot use the string decoder here, so we expected to get an error. diff --git a/node/tests/GlideClusterClient.test.ts b/node/tests/GlideClusterClient.test.ts index d21ff1a43a..a5de7425c1 100644 --- a/node/tests/GlideClusterClient.test.ts +++ b/node/tests/GlideClusterClient.test.ts @@ -34,7 +34,7 @@ import { SlotKeyTypes, SortOrder, } from ".."; -import { ValkeyCluster } from "../../utils/TestUtils.js"; +import { ValkeyCluster } from "../../utils/TestUtils"; import { runBaseTests } from "./SharedTests"; import { checkClusterResponse, @@ -291,33 +291,55 @@ describe("GlideClusterClient", () => { TIMEOUT, ); - it.each([ProtocolVersion.RESP2, ProtocolVersion.RESP3])( - `can send transactions_%p`, - async (protocol) => { - client = await GlideClusterClient.createClient( - getClientConfigurationOption(cluster.getAddresses(), protocol), - ); - const transaction = new ClusterTransaction(); + describe.each([ProtocolVersion.RESP2, ProtocolVersion.RESP3])( + "Protocol is RESP2 = %s", + (protocol) => { + describe.each([Decoder.String, Decoder.Bytes])( + "Decoder String = %s", + (decoder) => { + it( + "can send transactions", + async () => { + client = await GlideClusterClient.createClient( + getClientConfigurationOption( + cluster.getAddresses(), + protocol, + ), + ); - const expectedRes = await transactionTest( - transaction, - cluster.getVersion(), - ); + const transaction = new ClusterTransaction(); - if (!cluster.checkIfServerVersionLessThan("7.0.0")) { - transaction.publish("message", "key", true); - expectedRes.push(['publish("message", "key", true)', 0]); + const expectedRes = await transactionTest( + transaction, + cluster.getVersion(), + decoder, + ); - transaction.pubsubShardChannels(); - expectedRes.push(["pubsubShardChannels()", []]); - transaction.pubsubShardNumSub([]); - expectedRes.push(["pubsubShardNumSub()", []]); - } + if ( + !cluster.checkIfServerVersionLessThan("7.0.0") + ) { + transaction.publish("message", "key", true); + expectedRes.push([ + 'publish("message", "key", true)', + 0, + ]); - const result = await client.exec(transaction); - validateTransactionResponse(result, expectedRes); + transaction.pubsubShardChannels(); + expectedRes.push(["pubsubShardChannels()", []]); + transaction.pubsubShardNumSub([]); + expectedRes.push(["pubsubShardNumSub()", []]); + } + + const result = await client.exec(transaction, { + decoder: Decoder.String, + }); + validateTransactionResponse(result, expectedRes); + }, + TIMEOUT, + ); + }, + ); }, - TIMEOUT, ); it.each([ProtocolVersion.RESP2, ProtocolVersion.RESP3])( diff --git a/node/tests/SharedTests.ts b/node/tests/SharedTests.ts index 75d37cd316..e05b4b6c7a 100644 --- a/node/tests/SharedTests.ts +++ b/node/tests/SharedTests.ts @@ -10757,7 +10757,7 @@ export function runBaseTests(config: { ).toEqual("OK"); // one empty group exists - expect(await client.xinfoGroups(key)).toEqual( + expect(await client.xinfoGroups(Buffer.from(key))).toEqual( cluster.checkIfServerVersionLessThan("7.0.0") ? [ { diff --git a/node/tests/TestUtilities.ts b/node/tests/TestUtilities.ts index b79259c01d..bc3ef34499 100644 --- a/node/tests/TestUtilities.ts +++ b/node/tests/TestUtilities.ts @@ -17,6 +17,7 @@ import { BitmapIndexType, BitwiseOperation, ClusterTransaction, + Decoder, FlushMode, FunctionListResponse, FunctionStatsSingleResponse, @@ -653,7 +654,7 @@ export async function encodedTransactionTest( * @param valueResponse - Represents the encoded response of "value" to compare * @returns Array of tuples, where first element is a test name/description, second - expected return value. */ -export async function DumpAndRestureTest( +export async function DumpAndRestoreTest( baseTransaction: Transaction, valueResponse: GlideString, ): Promise<[string, GlideReturnType][]> { @@ -684,6 +685,17 @@ export async function DumpAndRestureTest( return responseData; } +/** + * @internal + */ +function decodeString(str: string, decoder: Decoder): GlideString { + if (decoder == Decoder.Bytes) { + return Buffer.from(str); + } + + return str; +} + /** * Populates a transaction with commands to test. * @param baseTransaction - A transaction. @@ -692,43 +704,108 @@ export async function DumpAndRestureTest( export async function transactionTest( baseTransaction: Transaction | ClusterTransaction, version: string, + decoder: Decoder, ): Promise<[string, GlideReturnType][]> { - const key1 = "{key}" + uuidv4(); // string - const key2 = "{key}" + uuidv4(); // string - const key3 = "{key}" + uuidv4(); // string - const key4 = "{key}" + uuidv4(); // hash - const key5 = "{key}" + uuidv4(); - const key6 = "{key}" + uuidv4(); - const key7 = "{key}" + uuidv4(); - const key8 = "{key}" + uuidv4(); - const key9 = "{key}" + uuidv4(); - const key10 = "{key}" + uuidv4(); - const key11 = "{key}" + uuidv4(); // hyper log log - const key12 = "{key}" + uuidv4(); - const key13 = "{key}" + uuidv4(); - const key14 = "{key}" + uuidv4(); // sorted set - const key15 = "{key}" + uuidv4(); // list - const key16 = "{key}" + uuidv4(); // list - const key17 = "{key}" + uuidv4(); // bitmap - const key18 = "{key}" + uuidv4(); // Geospatial Data/ZSET - const key19 = "{key}" + uuidv4(); // bitmap - const key20 = "{key}" + uuidv4(); // list - const key21 = "{key}" + uuidv4(); // list for sort - const key22 = "{key}" + uuidv4(); // list for sort - const key23 = "{key}" + uuidv4(); // zset random - const key24 = "{key}" + uuidv4(); // list value - const key25 = "{key}" + uuidv4(); // Geospatial Data/ZSET - const key26 = "{key}" + uuidv4(); // sorted set - const key27 = "{key}" + uuidv4(); // sorted set - const field = uuidv4(); - const value = uuidv4(); - const groupName1 = uuidv4(); - const groupName2 = uuidv4(); - const consumer = uuidv4(); + // initialize key values to work within the same hashslot + const [ + key1, // string + key2, // string + key3, // string + key4, // hash + key5, // list + key6, // list + key7, // set + key8, // sorted set + key9, // stream + key10, // string + key11, // hyper log log + key12, // sorted set + key13, // sorted set + key14, // sorted set + key15, // list + key16, // list + key17, // bitmap + key18, // Geospatial Data/ZSET + key19, // bitmap + key20, // list + key21, // list for sort + key22, // list for sort + key23, // zset random + key24, // list value + key25, // Geospatial Data/ZSET + key26, // sorted set + key27, // sorted set + ] = Array.from({ length: 27 }, () => + decodeString("{key}" + uuidv4(), decoder), + ); + + // initialize non-key values + const [value, groupName1, groupName2, consumer] = Array.from( + { length: 4 }, + () => decodeString(uuidv4(), decoder), + ); + + const fieldStr = uuidv4(); + const [ + field, + field1, + field2, + field3, + field4, + value1, + value2, + value3, + foo, + bar, + baz, + test, + one, + two, + three, + underscore, + non_existing_member, + member1, + member2, + member3, + member4, + member5, + member6, + member7, + palermo, + catania, + ] = [ + decodeString(fieldStr, decoder), + decodeString(fieldStr + 1, decoder), + decodeString(fieldStr + 2, decoder), + decodeString(fieldStr + 3, decoder), + decodeString(fieldStr + 4, decoder), + decodeString("value1", decoder), + decodeString("value2", decoder), + decodeString("value3", decoder), + decodeString("foo", decoder), + decodeString("bar", decoder), + decodeString("baz", decoder), + decodeString("test_message", decoder), + decodeString("one", decoder), + decodeString("two", decoder), + decodeString("three", decoder), + decodeString("_", decoder), + decodeString("non_existing_member", decoder), + decodeString("member1", decoder), + decodeString("member2", decoder), + decodeString("member3", decoder), + decodeString("member4", decoder), + decodeString("member5", decoder), + decodeString("member6", decoder), + decodeString("member7", decoder), + decodeString("Palermo", decoder), + decodeString("Catania", decoder), + ]; + // array of tuples - first element is test name/description, second - expected return value const responseData: [string, GlideReturnType][] = []; - baseTransaction.publish("test_message", key1); + baseTransaction.publish(test, key1); responseData.push(['publish("test_message", key1)', 0]); baseTransaction.pubsubChannels(); responseData.push(["pubsubChannels()", []]); @@ -747,9 +824,9 @@ export async function transactionTest( responseData.push(["flushdb(FlushMode.SYNC)", "OK"]); baseTransaction.dbsize(); responseData.push(["dbsize()", 0]); - baseTransaction.set(key1, "foo"); - responseData.push(['set(key1, "bar")', "OK"]); - baseTransaction.set(key1, "bar", { returnOldValue: true }); + baseTransaction.set(key1, foo); + responseData.push(['set(key1, "foo")', "OK"]); + baseTransaction.set(key1, bar, { returnOldValue: true }); responseData.push(['set(key1, "bar", {returnOldValue: true})', "foo"]); if (gte(version, "6.2.0")) { @@ -763,19 +840,19 @@ export async function transactionTest( } baseTransaction.randomKey(); - responseData.push(["randomKey()", key1]); + responseData.push(["randomKey()", key1.toString()]); baseTransaction.getrange(key1, 0, -1); responseData.push(["getrange(key1, 0, -1)", "bar"]); baseTransaction.getdel(key1); responseData.push(["getdel(key1)", "bar"]); - baseTransaction.set(key1, "bar"); + baseTransaction.set(key1, bar); responseData.push(['set(key1, "bar")', "OK"]); baseTransaction.objectEncoding(key1); responseData.push(["objectEncoding(key1)", "embstr"]); baseTransaction.type(key1); responseData.push(["type(key1)", "string"]); baseTransaction.echo(value); - responseData.push(["echo(value)", value]); + responseData.push(["echo(value)", value.toString()]); baseTransaction.persist(key1); responseData.push(["persist(key1)", false]); @@ -787,13 +864,13 @@ export async function transactionTest( responseData.push(["pexpiretime(key1)", -1]); } - baseTransaction.set(key2, "baz", { returnOldValue: true }); + baseTransaction.set(key2, baz, { returnOldValue: true }); responseData.push(['set(key2, "baz", { returnOldValue: true })', null]); baseTransaction.customCommand(["MGET", key1, key2]); responseData.push(['customCommand(["MGET", key1, key2])', ["bar", "baz"]]); - baseTransaction.mset({ [key3]: value }); + baseTransaction.mset([{ key: key3, value }]); responseData.push(["mset({ [key3]: value })", "OK"]); - baseTransaction.msetnx({ [key3]: value }); + baseTransaction.msetnx([{ key: key3, value }]); responseData.push(["msetnx({ [key3]: value })", false]); baseTransaction.mget([key1, key2]); responseData.push(["mget([key1, key2])", ["bar", "baz"]]); @@ -810,13 +887,16 @@ export async function transactionTest( baseTransaction.hset(key4, [{ field, value }]); responseData.push(["hset(key4, { [field]: value })", 1]); baseTransaction.hscan(key4, "0"); - responseData.push(['hscan(key4, "0")', ["0", [field, value]]]); + responseData.push([ + 'hscan(key4, "0")', + ["0", [field.toString(), value.toString()]], + ]); if (gte(version, "7.9.0")) { baseTransaction.hscan(key4, "0", { noValues: false }); responseData.push([ 'hscan(key4, "0", {noValues: false})', - ["0", [field, value]], + ["0", [field.toString(), value.toString()]], ]); baseTransaction.hscan(key4, "0", { match: "*", @@ -825,37 +905,43 @@ export async function transactionTest( }); responseData.push([ 'hscan(key4, "0", {match: "*", count: 20, noValues:true})', - ["0", [field]], + ["0", [field.toString()]], ]); } baseTransaction.hscan(key4, "0", { match: "*", count: 20 }); responseData.push([ 'hscan(key4, "0", {match: "*", count: 20})', - ["0", [field, value]], + ["0", [field.toString(), value.toString()]], ]); baseTransaction.hstrlen(key4, field); responseData.push(["hstrlen(key4, field)", value.length]); baseTransaction.hlen(key4); responseData.push(["hlen(key4)", 1]); baseTransaction.hrandfield(key4); - responseData.push(["hrandfield(key4)", field]); + responseData.push(["hrandfield(key4)", field.toString()]); baseTransaction.hrandfieldCount(key4, -2); - responseData.push(["hrandfieldCount(key4, -2)", [field, field]]); + responseData.push([ + "hrandfieldCount(key4, -2)", + [field.toString(), field.toString()], + ]); baseTransaction.hrandfieldWithValues(key4, 2); - responseData.push(["hrandfieldWithValues(key4, 2)", [[field, value]]]); + responseData.push([ + "hrandfieldWithValues(key4, 2)", + [[field.toString(), value.toString()]], + ]); baseTransaction.hsetnx(key4, field, value); responseData.push(["hsetnx(key4, field, value)", false]); baseTransaction.hvals(key4); - responseData.push(["hvals(key4)", [value]]); + responseData.push(["hvals(key4)", [value.toString()]]); baseTransaction.hkeys(key4); - responseData.push(["hkeys(key4)", [field]]); + responseData.push(["hkeys(key4)", [field.toString()]]); baseTransaction.hget(key4, field); - responseData.push(["hget(key4, field)", value]); + responseData.push(["hget(key4, field)", value.toString()]); baseTransaction.hgetall(key4); responseData.push([ "hgetall(key4)", - convertRecordToGlideRecord({ [field]: value }), + [{ key: field.toString(), value: value.toString() }], ]); baseTransaction.hdel(key4, [field]); responseData.push(["hdel(key4, [field])", 1]); @@ -866,43 +952,41 @@ export async function transactionTest( baseTransaction.hrandfield(key4); responseData.push(["hrandfield(key4)", null]); - baseTransaction.lpush(key5, [ - field + "1", - field + "2", - field + "3", - field + "4", - ]); + baseTransaction.lpush(key5, [field1, field2, field3, field4]); responseData.push(["lpush(key5, [1, 2, 3, 4])", 4]); if (gte("7.0.0", version)) { - baseTransaction.lpush(key24, [field + "1", field + "2"]); + baseTransaction.lpush(key24, [field1, field2]); responseData.push(["lpush(key22, [1, 2])", 2]); baseTransaction.lmpop([key24], ListDirection.LEFT); responseData.push([ "lmpop([key22], ListDirection.LEFT)", - { [key24]: [field + "2"] }, + [{ key: key24, elements: [field2] }], ]); - baseTransaction.lpush(key24, [field + "2"]); + baseTransaction.lpush(key24, [field2]); responseData.push(["lpush(key22, [2])", 2]); baseTransaction.blmpop([key24], ListDirection.LEFT, 0.1, 1); responseData.push([ "blmpop([key22], ListDirection.LEFT, 0.1, 1)", - { [key24]: [field + "2"] }, + [{ key: key24, elements: [field2] }], ]); } baseTransaction.lpop(key5); - responseData.push(["lpop(key5)", field + "4"]); + responseData.push(["lpop(key5)", field4.toString()]); baseTransaction.llen(key5); responseData.push(["llen(key5)", 3]); - baseTransaction.lrem(key5, 1, field + "1"); + baseTransaction.lrem(key5, 1, field1); responseData.push(['lrem(key5, 1, field + "1")', 1]); baseTransaction.ltrim(key5, 0, 1); responseData.push(["ltrim(key5, 0, 1)", "OK"]); - baseTransaction.lset(key5, 0, field + "3"); + baseTransaction.lset(key5, 0, field3); responseData.push(['lset(key5, 0, field + "3")', "OK"]); baseTransaction.lrange(key5, 0, -1); - responseData.push(["lrange(key5, 0, -1)", [field + "3", field + "2"]]); + responseData.push([ + "lrange(key5, 0, -1)", + [field3.toString(), field2.toString()], + ]); if (gte(version, "6.2.0")) { baseTransaction.lmove( @@ -913,7 +997,7 @@ export async function transactionTest( ); responseData.push([ "lmove(key5, key20, ListDirection.LEFT, ListDirection.LEFT)", - field + "3", + field3.toString(), ]); baseTransaction.blmove( @@ -925,12 +1009,15 @@ export async function transactionTest( ); responseData.push([ "blmove(key20, key5, ListDirection.LEFT, ListDirection.LEFT, 3)", - field + "3", + field3.toString(), ]); } baseTransaction.lpopCount(key5, 2); - responseData.push(["lpopCount(key5, 2)", [field + "3", field + "2"]]); + responseData.push([ + "lpopCount(key5, 2)", + [field3.toString(), field2.toString()], + ]); baseTransaction.linsert( key5, @@ -939,34 +1026,31 @@ export async function transactionTest( "element", ); responseData.push(["linsert", 0]); - baseTransaction.rpush(key6, [field + "1", field + "2", field + "3"]); + baseTransaction.rpush(key6, [field1, field2, field3]); responseData.push([ 'rpush(key6, [field + "1", field + "2", field + "3"])', 3, ]); baseTransaction.lindex(key6, 0); - responseData.push(["lindex(key6, 0)", field + "1"]); + responseData.push(["lindex(key6, 0)", field1.toString()]); baseTransaction.rpop(key6); - responseData.push(["rpop(key6)", field + "3"]); + responseData.push(["rpop(key6)", field3.toString()]); baseTransaction.rpopCount(key6, 2); - responseData.push(["rpopCount(key6, 2)", [field + "2", field + "1"]]); - baseTransaction.rpushx(key15, ["_"]); // key15 is empty + responseData.push([ + "rpopCount(key6, 2)", + [field2.toString(), field1.toString()], + ]); + baseTransaction.rpushx(key15, [underscore]); // key15 is empty responseData.push(['rpushx(key15, ["_"])', 0]); - baseTransaction.lpushx(key15, ["_"]); + baseTransaction.lpushx(key15, [underscore]); responseData.push(['lpushx(key15, ["_"])', 0]); - baseTransaction.rpush(key16, [ - field + "1", - field + "1", - field + "2", - field + "3", - field + "3", - ]); + baseTransaction.rpush(key16, [field1, field1, field2, field3, field3]); responseData.push(["rpush(key16, [1, 1, 2, 3, 3,])", 5]); - baseTransaction.lpos(key16, field + "1", { rank: 2 }); - responseData.push(['lpos(key16, field + "1", { rank: 2 })', 1]); - baseTransaction.lpos(key16, field + "1", { rank: 2, count: 0 }); - responseData.push(['lpos(key16, field + "1", { rank: 2, count: 0 })', [1]]); - baseTransaction.sadd(key7, ["bar", "foo"]); + baseTransaction.lpos(key16, field1, { rank: 2 }); + responseData.push(["lpos(key16, field1, { rank: 2 })", 1]); + baseTransaction.lpos(key16, field1, { rank: 2, count: 0 }); + responseData.push(["lpos(key16, field1, { rank: 2, count: 0 })", [1]]); + baseTransaction.sadd(key7, [bar, foo]); responseData.push(['sadd(key7, ["bar", "foo"])', 2]); baseTransaction.sunionstore(key7, [key7, key7]); responseData.push(["sunionstore(key7, [key7, key7])", 2]); @@ -988,7 +1072,7 @@ export async function transactionTest( responseData.push(["sdiff([key7, key7])", new Set()]); baseTransaction.sdiffstore(key7, [key7]); responseData.push(["sdiffstore(key7, [key7])", 2]); - baseTransaction.srem(key7, ["foo"]); + baseTransaction.srem(key7, [foo]); responseData.push(['srem(key7, ["foo"])', 1]); baseTransaction.sscan(key7, "0"); responseData.push(['sscan(key7, "0")', ["0", ["bar"]]]); @@ -999,11 +1083,11 @@ export async function transactionTest( ]); baseTransaction.scard(key7); responseData.push(["scard(key7)", 1]); - baseTransaction.sismember(key7, "bar"); + baseTransaction.sismember(key7, bar); responseData.push(['sismember(key7, "bar")', true]); if (gte(version, "6.2.0")) { - baseTransaction.smismember(key7, ["bar", "foo", "baz"]); + baseTransaction.smismember(key7, [bar, foo, baz]); responseData.push([ 'smismember(key7, ["bar", "foo", "baz"])', [true, false, false], @@ -1022,23 +1106,23 @@ export async function transactionTest( responseData.push(["spop(key7)", "bar"]); baseTransaction.spopCount(key7, 2); responseData.push(["spopCount(key7, 2)", new Set()]); - baseTransaction.smove(key7, key7, "non_existing_member"); + baseTransaction.smove(key7, key7, non_existing_member); responseData.push(['smove(key7, key7, "non_existing_member")', false]); baseTransaction.scard(key7); responseData.push(["scard(key7)", 0]); - baseTransaction.zadd(key8, { - member1: 1, - member2: 2, - member3: 3.5, - member4: 4, - member5: 5, - }); + baseTransaction.zadd(key8, [ + { element: member1, score: 1 }, + { element: member2, score: 2 }, + { element: member3, score: 3.5 }, + { element: member4, score: 4 }, + { element: member5, score: 5 }, + ]); responseData.push(["zadd(key8, { ... } ", 5]); - baseTransaction.zrank(key8, "member1"); + baseTransaction.zrank(key8, member1); responseData.push(['zrank(key8, "member1")', 0]); if (gte(version, "7.2.0")) { - baseTransaction.zrankWithScore(key8, "member1"); + baseTransaction.zrankWithScore(key8, member1); responseData.push(['zrankWithScore(key8, "member1")', [0, 1]]); } @@ -1050,21 +1134,26 @@ export async function transactionTest( responseData.push(['zrevrankWithScore(key8, "member5")', [0, 5]]); } - baseTransaction.zaddIncr(key8, "member2", 1); + baseTransaction.zaddIncr(key8, member2, 1); responseData.push(['zaddIncr(key8, "member2", 1)', 3]); - baseTransaction.zincrby(key8, 0.3, "member1"); + baseTransaction.zincrby(key8, 0.3, member1); responseData.push(['zincrby(key8, 0.3, "member1")', 1.3]); - baseTransaction.zrem(key8, ["member1"]); + baseTransaction.zrem(key8, [member1]); responseData.push(['zrem(key8, ["member1"])', 1]); baseTransaction.zcard(key8); responseData.push(["zcard(key8)", 4]); - baseTransaction.zscore(key8, "member2"); + baseTransaction.zscore(key8, member2); responseData.push(['zscore(key8, "member2")', 3.0]); baseTransaction.zrange(key8, { start: 0, end: -1 }); responseData.push([ "zrange(key8, { start: 0, end: -1 })", - ["member2", "member3", "member4", "member5"], + [ + member2.toString(), + member3.toString(), + member4.toString(), + member5.toString(), + ], ]); baseTransaction.zrangeWithScores(key8, { start: 0, end: -1 }); responseData.push([ @@ -1076,7 +1165,10 @@ export async function transactionTest( member5: 5, }), ]); - baseTransaction.zadd(key12, { one: 1, two: 2 }); + baseTransaction.zadd(key12, [ + { element: one, score: 1 }, + { element: two, score: 2 }, + ]); responseData.push(["zadd(key12, { one: 1, two: 2 })", 2]); baseTransaction.zscan(key12, "0"); responseData.push(['zscan(key12, "0")', ["0", ["one", "1", "two", "2"]]]); @@ -1085,7 +1177,7 @@ export async function transactionTest( baseTransaction.zscan(key12, "0", { noScores: false }); responseData.push([ 'zscan(key12, "0", {noScores: false})', - ["0", ["one", "1", "two", "2"]], + ["0", [one.toString(), "1", two.toString(), "2"]], ]); baseTransaction.zscan(key12, "0", { @@ -1095,7 +1187,7 @@ export async function transactionTest( }); responseData.push([ 'zscan(key12, "0", {match: "*", count: 20, noScores:true})', - ["0", ["one", "two"]], + ["0", [one.toString(), two.toString()]], ]); } @@ -1130,9 +1222,16 @@ export async function transactionTest( responseData.push(["zinterstore(key12, [key12, key13])", 0]); if (gte(version, "6.2.0")) { - baseTransaction.zadd(key26, { one: 1, two: 2 }); + baseTransaction.zadd(key26, [ + { element: one, score: 1 }, + { element: two, score: 2 }, + ]); responseData.push(["zadd(key26, { one: 1, two: 2 })", 2]); - baseTransaction.zadd(key27, { one: 1, two: 2, three: 3.5 }); + baseTransaction.zadd(key27, [ + { element: one, score: 1 }, + { element: two, score: 2 }, + { element: three, score: 3.5 }, + ]); responseData.push([ "zadd(key27, { one: 1, two: 2, three: 3.5 })", 3, @@ -1181,14 +1280,20 @@ export async function transactionTest( "zpopmax(key8)", convertRecordToGlideRecord({ member5: 5 }), ]); - baseTransaction.zadd(key8, { member6: 6 }); + baseTransaction.zadd(key8, [{ element: member6, score: 6 }]); responseData.push(["zadd(key8, {member6: 6})", 1]); baseTransaction.bzpopmax([key8], 0.5); - responseData.push(["bzpopmax([key8], 0.5)", [key8, "member6", 6]]); - baseTransaction.zadd(key8, { member7: 1 }); + responseData.push([ + "bzpopmax([key8], 0.5)", + [key8.toString(), "member6", 6], + ]); + baseTransaction.zadd(key8, [{ element: member7, score: 1 }]); responseData.push(["zadd(key8, {member7: 1})", 1]); baseTransaction.bzpopmin([key8], 0.5); - responseData.push(["bzpopmin([key8], 0.5)", [key8, "member7", 1]]); + responseData.push([ + "bzpopmin([key8], 0.5)", + [key8.toString(), "member7", 1], + ]); baseTransaction.zremRangeByRank(key8, 1, 1); responseData.push(["zremRangeByRank(key8, 1, 1)", 1]); baseTransaction.zremRangeByScore( @@ -1205,7 +1310,10 @@ export async function transactionTest( responseData.push(["zremRangeByLex(key8, -Inf, +Inf)", 0]); // key8 is already empty if (gte(version, "7.0.0")) { - baseTransaction.zadd(key14, { one: 1.0, two: 2.0 }); + baseTransaction.zadd(key14, [ + { element: one, score: 1.0 }, + { element: two, score: 2.0 }, + ]); responseData.push(["zadd(key14, { one: 1.0, two: 2.0 })", 2]); baseTransaction.zintercard([key8, key14]); responseData.push(["zintercard([key8, key14])", 0]); @@ -1214,38 +1322,41 @@ export async function transactionTest( baseTransaction.zmpop([key14], ScoreFilter.MAX); responseData.push([ "zmpop([key14], MAX)", - [key14, convertRecordToGlideRecord({ two: 2.0 })], + [key14.toString(), [{ key: "two", value: 2.0 }]], ]); baseTransaction.zmpop([key14], ScoreFilter.MAX, 1); responseData.push([ "zmpop([key14], MAX, 1)", - [key14, convertRecordToGlideRecord({ one: 1.0 })], + [key14.toString(), [{ key: "one", value: 1.0 }]], + ]); + baseTransaction.zadd(key14, [ + { element: one, score: 1.0 }, + { element: two, score: 2.0 }, ]); - baseTransaction.zadd(key14, { one: 1.0, two: 2.0 }); responseData.push(["zadd(key14, { one: 1.0, two: 2.0 })", 2]); baseTransaction.bzmpop([key14], ScoreFilter.MAX, 0.1); responseData.push([ "bzmpop([key14], ScoreFilter.MAX, 0.1)", - [key14, convertRecordToGlideRecord({ two: 2.0 })], + [key14.toString(), [{ key: "two", value: 2.0 }]], ]); baseTransaction.bzmpop([key14], ScoreFilter.MAX, 0.1, 1); responseData.push([ "bzmpop([key14], ScoreFilter.MAX, 0.1, 1)", - [key14, convertRecordToGlideRecord({ one: 1.0 })], + [key14.toString(), [{ key: "one", value: 1.0 }]], ]); } - baseTransaction.xadd(key9, [["field", "value1"]], { id: "0-1" }); + baseTransaction.xadd(key9, [[field, value1]], { id: "0-1" }); responseData.push([ 'xadd(key9, [["field", "value1"]], { id: "0-1" })', "0-1", ]); - baseTransaction.xadd(key9, [["field", "value2"]], { id: "0-2" }); + baseTransaction.xadd(key9, [[field, value2]], { id: "0-2" }); responseData.push([ 'xadd(key9, [["field", "value2"]], { id: "0-2" })', "0-2", ]); - baseTransaction.xadd(key9, [["field", "value3"]], { id: "0-3" }); + baseTransaction.xadd(key9, [[field, value3]], { id: "0-3" }); responseData.push([ 'xadd(key9, [["field", "value3"]], { id: "0-3" })', "0-3", @@ -1255,22 +1366,35 @@ export async function transactionTest( baseTransaction.xrange(key9, { value: "0-1" }, { value: "0-1" }); responseData.push([ "xrange(key9)", - convertRecordToGlideRecord({ "0-1": [["field", "value1"]] }), + convertRecordToGlideRecord({ + "0-1": [[field.toString(), value1.toString()]], + }), ]); baseTransaction.xrevrange(key9, { value: "0-1" }, { value: "0-1" }); responseData.push([ "xrevrange(key9)", - convertRecordToGlideRecord({ "0-1": [["field", "value1"]] }), + convertRecordToGlideRecord({ + "0-1": [[field.toString(), value1.toString()]], + }), ]); - baseTransaction.xread({ [key9]: "0-1" }); + baseTransaction.xread([{ key: key9, value: "0-1" }]); responseData.push([ 'xread({ [key9]: "0-1" })', - convertRecordToGlideRecord({ - [key9]: convertRecordToGlideRecord({ - "0-2": [["field", "value2"]], - "0-3": [["field", "value3"]], - }), - }), + [ + { + key: key9.toString(), + value: [ + { + key: "0-2", + value: [[field.toString(), value2.toString()]], + }, + { + key: "0-3", + value: [[field.toString(), value3.toString()]], + }, + ], + }, + ], ]); baseTransaction.xtrim(key9, { method: "minid", @@ -1302,19 +1426,27 @@ export async function transactionTest( "xgroupCreateConsumer(key9, groupName1, consumer)", true, ]); - baseTransaction.xreadgroup(groupName1, consumer, { [key9]: ">" }); + baseTransaction.xreadgroup(groupName1, consumer, [ + { key: key9, value: ">" }, + ]); responseData.push([ 'xreadgroup(groupName1, consumer, {[key9]: ">"})', - convertRecordToGlideRecord({ - [key9]: convertRecordToGlideRecord({ - "0-2": [["field", "value2"]], - }), - }), + [ + { + key: key9.toString(), + value: [ + { + key: "0-2", + value: [[field.toString(), value2.toString()]], + }, + ], + }, + ], ]); baseTransaction.xpending(key9, groupName1); responseData.push([ "xpending(key9, groupName1)", - [1, "0-2", "0-2", [[consumer, "1"]]], + [1, "0-2", "0-2", [[consumer.toString(), "1"]]], ]); baseTransaction.xpendingWithOptions(key9, groupName1, { start: InfBoundary.NegativeInfinity, @@ -1323,12 +1455,14 @@ export async function transactionTest( }); responseData.push([ "xpendingWithOptions(key9, groupName1, -, +, 10)", - [["0-2", consumer, 0, 1]], + [["0-2", consumer.toString(), 0, 1]], ]); baseTransaction.xclaim(key9, groupName1, consumer, 0, ["0-2"]); responseData.push([ 'xclaim(key9, groupName1, consumer, 0, ["0-2"])', - convertRecordToGlideRecord({ "0-2": [["field", "value2"]] }), + convertRecordToGlideRecord({ + "0-2": [[field.toString(), value2.toString()]], + }), ]); baseTransaction.xclaim(key9, groupName1, consumer, 0, ["0-2"], { isForce: true, @@ -1337,7 +1471,9 @@ export async function transactionTest( }); responseData.push([ 'xclaim(key9, groupName1, consumer, 0, ["0-2"], { isForce: true, retryCount: 0, idle: 0})', - convertRecordToGlideRecord({ "0-2": [["field", "value2"]] }), + convertRecordToGlideRecord({ + "0-2": [[field.toString(), value2.toString()]], + }), ]); baseTransaction.xclaimJustId(key9, groupName1, consumer, 0, ["0-2"]); responseData.push([ @@ -1364,14 +1500,14 @@ export async function transactionTest( ? [ "0-0", convertRecordToGlideRecord({ - "0-2": [["field", "value2"]], + "0-2": [[field.toString(), value2.toString()]], }), [], ] : [ "0-0", convertRecordToGlideRecord({ - "0-2": [["field", "value2"]], + "0-2": [[field.toString(), value2.toString()]], }), ], ]); @@ -1403,15 +1539,21 @@ export async function transactionTest( responseData.push(["renamenx(key10, key9)", true]); baseTransaction.exists([key9, key10]); responseData.push(["exists([key9, key10])", 1]); - baseTransaction.rpush(key6, [field + "1", field + "2", field + "3"]); + baseTransaction.rpush(key6, [field1, field2, field3]); responseData.push([ 'rpush(key6, [field + "1", field + "2", field + "3"])', 3, ]); baseTransaction.brpop([key6], 0.1); - responseData.push(["brpop([key6], 0.1)", [key6, field + "3"]]); + responseData.push([ + "brpop([key6], 0.1)", + [key6.toString(), field3.toString()], + ]); baseTransaction.blpop([key6], 0.1); - responseData.push(["blpop([key6], 0.1)", [key6, field + "1"]]); + responseData.push([ + "blpop([key6], 0.1)", + [key6.toString(), field1.toString()], + ]); baseTransaction.setbit(key17, 1, 1); responseData.push(["setbit(key17, 1, 1)", 0]); @@ -1481,21 +1623,21 @@ export async function transactionTest( ]); responseData.push(["bitfield(key17, [new BitFieldSet(...)])", [609]]); - baseTransaction.pfadd(key11, ["a", "b", "c"]); - responseData.push(['pfadd(key11, ["a", "b", "c"])', 1]); + baseTransaction.pfadd(key11, [one, two, three]); + responseData.push(["pfadd(key11, [one, two, three])", 1]); baseTransaction.pfmerge(key11, []); responseData.push(["pfmerge(key11, [])", "OK"]); baseTransaction.pfcount([key11]); responseData.push(["pfcount([key11])", 3]); baseTransaction.geoadd( key18, - new Map([ - ["Palermo", { longitude: 13.361389, latitude: 38.115556 }], - ["Catania", { longitude: 15.087269, latitude: 37.502669 }], + new Map([ + [palermo, { longitude: 13.361389, latitude: 38.115556 }], + [catania, { longitude: 15.087269, latitude: 37.502669 }], ]), ); responseData.push(["geoadd(key18, { Palermo: ..., Catania: ... })", 2]); - baseTransaction.geopos(key18, ["Palermo", "Catania"]); + baseTransaction.geopos(key18, [palermo, catania]); responseData.push([ 'geopos(key18, ["Palermo", "Catania"])', [ @@ -1503,16 +1645,16 @@ export async function transactionTest( [15.08726745843887329, 37.50266842333162032], ], ]); - baseTransaction.geodist(key18, "Palermo", "Catania"); + baseTransaction.geodist(key18, palermo, catania); responseData.push(['geodist(key18, "Palermo", "Catania")', 166274.1516]); - baseTransaction.geodist(key18, "Palermo", "Catania", { + baseTransaction.geodist(key18, palermo, catania, { unit: GeoUnit.KILOMETERS, }); responseData.push([ 'geodist(key18, "Palermo", "Catania", { unit: GeoUnit.KILOMETERS })', 166.2742, ]); - baseTransaction.geohash(key18, ["Palermo", "Catania", "NonExisting"]); + baseTransaction.geohash(key18, [palermo, catania, non_existing_member]); responseData.push([ 'geohash(key18, ["Palermo", "Catania", "NonExisting"])', ["sqc8b49rny0", "sqdtr74hyu0", null], @@ -1533,7 +1675,7 @@ export async function transactionTest( baseTransaction .geosearch( key18, - { member: "Palermo" }, + { member: palermo }, { radius: 200, unit: GeoUnit.KILOMETERS }, { sortOrder: SortOrder.ASC }, ) @@ -1544,7 +1686,7 @@ export async function transactionTest( ) .geosearch( key18, - { member: "Palermo" }, + { member: palermo }, { radius: 200, unit: GeoUnit.KILOMETERS }, { sortOrder: SortOrder.ASC, @@ -1568,17 +1710,17 @@ export async function transactionTest( ); responseData.push([ 'geosearch(key18, "Palermo", R200 KM, ASC)', - ["Palermo", "Catania"], + [palermo.toString(), catania.toString()], ]); responseData.push([ "geosearch(key18, (15, 37), 400x400 KM, ASC)", - ["Palermo", "Catania"], + [palermo.toString(), catania.toString()], ]); responseData.push([ 'geosearch(key18, "Palermo", R200 KM, ASC 2 3x true)', [ [ - "Palermo", + palermo.toString(), [ 0.0, 3479099956230698, @@ -1586,7 +1728,7 @@ export async function transactionTest( ], ], [ - "Catania", + catania.toString(), [ 166.2742, 3479447370796909, @@ -1599,7 +1741,7 @@ export async function transactionTest( "geosearch(key18, (15, 37), 400x400 KM, ASC 2 3x true)", [ [ - "Catania", + catania.toString(), [ 56.4413, 3479447370796909, @@ -1607,7 +1749,7 @@ export async function transactionTest( ], ], [ - "Palermo", + palermo.toString(), [ 190.4424, 3479099956230698, @@ -1681,7 +1823,11 @@ export async function transactionTest( responseData.push(["functionList({ libName, true})", []]); baseTransaction - .mset({ [key1]: "abcd", [key2]: "bcde", [key3]: "wxyz" }) + .mset([ + { key: key1, value: "abcd" }, + { key: key2, value: "bcde" }, + { key: key3, value: "wxyz" }, + ]) .lcs(key1, key2) .lcs(key1, key3) .lcsLen(key1, key2)