Skip to content

Commit

Permalink
Node: update transactions binary args returns (#2193)
Browse files Browse the repository at this point in the history
Node: update transactions binary args returns (#2193)

---------

Signed-off-by: Andrew Carbonetto <[email protected]>
  • Loading branch information
acarbonetto authored Dec 11, 2024
1 parent 085964c commit a5e3aea
Show file tree
Hide file tree
Showing 3 changed files with 477 additions and 234 deletions.
49 changes: 33 additions & 16 deletions node/tests/GlideClient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,23 +269,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(),
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,
decoder,
);
transaction.select(0);
const result = await client.exec(transaction, {
decoder: Decoder.String,
});
expectedRes.push(["select(0)", "OK"]);

validateTransactionResponse(result, expectedRes);
client.close();
},
TIMEOUT,
);
},
);
transaction.select(0);
const result = await client.exec(transaction);
expectedRes.push(["select(0)", "OK"]);

validateTransactionResponse(result, expectedRes);
client.close();
},
);

Expand Down
68 changes: 45 additions & 23 deletions node/tests/GlideClusterClient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import {
SortOrder,
convertRecordToGlideRecord,
} from "..";
import { ValkeyCluster } from "../../utils/TestUtils.js";
import { ValkeyCluster } from "../../utils/TestUtils";
import { runBaseTests } from "./SharedTests";
import {
checkClusterResponse,
Expand Down Expand Up @@ -328,33 +328,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,
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])(
Expand Down
Loading

0 comments on commit a5e3aea

Please sign in to comment.