You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-06 02:15:48 +03:00
Update doctest client with latest v4 release (#2844)
This commit is contained in:
@@ -11,7 +11,10 @@ describe('EXPLAIN', () => {
|
||||
});
|
||||
|
||||
testUtils.testWithClient('client.graph.explain', async client => {
|
||||
const reply = await client.graph.explain('key', 'RETURN 0');
|
||||
const [, reply] = await Promise.all([
|
||||
client.graph.query('key', 'RETURN 0'), // make sure to create a graph first
|
||||
client.graph.explain('key', 'RETURN 0')
|
||||
]);
|
||||
assert.ok(Array.isArray(reply));
|
||||
assert.ok(!reply.find(x => typeof x !== 'string'));
|
||||
}, GLOBAL.SERVERS.OPEN);
|
||||
|
@@ -6,4 +6,4 @@ export function transformArguments(key: string, query: string): Array<string> {
|
||||
return ['GRAPH.EXPLAIN', key, query];
|
||||
}
|
||||
|
||||
export declare function transfromReply(): Array<string>;
|
||||
export declare function transformReply(): Array<string>;
|
||||
|
@@ -6,4 +6,4 @@ export function transformArguments(key: string, query: string): Array<string> {
|
||||
return ['GRAPH.PROFILE', key, query];
|
||||
}
|
||||
|
||||
export declare function transfromReply(): Array<string>;
|
||||
export declare function transformReply(): Array<string>;
|
||||
|
@@ -11,7 +11,10 @@ describe('RO_QUERY', () => {
|
||||
});
|
||||
|
||||
testUtils.testWithClient('client.graph.roQuery', async client => {
|
||||
const { data } = await client.graph.roQuery('key', 'RETURN 0');
|
||||
const [, { data }] = await Promise.all([
|
||||
client.graph.query('key', 'RETURN 0'), // make sure to create a graph first
|
||||
client.graph.roQuery('key', 'RETURN 0')
|
||||
]);
|
||||
assert.deepEqual(data, [[0]]);
|
||||
}, GLOBAL.SERVERS.OPEN);
|
||||
});
|
@@ -5,7 +5,7 @@ import Graph from './graph';
|
||||
describe('Graph', () => {
|
||||
testUtils.testWithClient('null', async client => {
|
||||
const graph = new Graph(client as any, 'graph'),
|
||||
{ data } = await graph.roQuery('RETURN null AS key');
|
||||
{ data } = await graph.query('RETURN null AS key');
|
||||
|
||||
assert.deepEqual(
|
||||
data,
|
||||
@@ -15,7 +15,7 @@ describe('Graph', () => {
|
||||
|
||||
testUtils.testWithClient('string', async client => {
|
||||
const graph = new Graph(client as any, 'graph'),
|
||||
{ data } = await graph.roQuery('RETURN "string" AS key');
|
||||
{ data } = await graph.query('RETURN "string" AS key');
|
||||
|
||||
assert.deepEqual(
|
||||
data,
|
||||
@@ -25,7 +25,7 @@ describe('Graph', () => {
|
||||
|
||||
testUtils.testWithClient('integer', async client => {
|
||||
const graph = new Graph(client as any, 'graph'),
|
||||
{ data } = await graph.roQuery('RETURN 0 AS key');
|
||||
{ data } = await graph.query('RETURN 0 AS key');
|
||||
|
||||
assert.deepEqual(
|
||||
data,
|
||||
@@ -35,7 +35,7 @@ describe('Graph', () => {
|
||||
|
||||
testUtils.testWithClient('boolean', async client => {
|
||||
const graph = new Graph(client as any, 'graph'),
|
||||
{ data } = await graph.roQuery('RETURN false AS key');
|
||||
{ data } = await graph.query('RETURN false AS key');
|
||||
|
||||
assert.deepEqual(
|
||||
data,
|
||||
@@ -45,7 +45,7 @@ describe('Graph', () => {
|
||||
|
||||
testUtils.testWithClient('double', async client => {
|
||||
const graph = new Graph(client as any, 'graph'),
|
||||
{ data } = await graph.roQuery('RETURN 0.1 AS key');
|
||||
{ data } = await graph.query('RETURN 0.1 AS key');
|
||||
|
||||
assert.deepEqual(
|
||||
data,
|
||||
@@ -55,7 +55,7 @@ describe('Graph', () => {
|
||||
|
||||
testUtils.testWithClient('array', async client => {
|
||||
const graph = new Graph(client as any, 'graph'),
|
||||
{ data } = await graph.roQuery('RETURN [null] AS key');
|
||||
{ data } = await graph.query('RETURN [null] AS key');
|
||||
|
||||
assert.deepEqual(
|
||||
data,
|
||||
@@ -68,7 +68,7 @@ describe('Graph', () => {
|
||||
|
||||
// check with and without metadata cache
|
||||
for (let i = 0; i < 2; i++) {
|
||||
const { data } = await graph.query('CREATE ()-[edge :edge]->() RETURN edge');
|
||||
const { data } = await graph.query<any>('CREATE ()-[edge :edge]->() RETURN edge');
|
||||
assert.ok(Array.isArray(data));
|
||||
assert.equal(data.length, 1);
|
||||
assert.equal(typeof data[0].edge.id, 'number');
|
||||
@@ -85,7 +85,7 @@ describe('Graph', () => {
|
||||
|
||||
// check with and without metadata cache
|
||||
for (let i = 0; i < 2; i++) {
|
||||
const { data } = await graph.query('CREATE (node :node { p: 0 }) RETURN node');
|
||||
const { data } = await graph.query<any>('CREATE (node :node { p: 0 }) RETURN node');
|
||||
assert.ok(Array.isArray(data));
|
||||
assert.equal(data.length, 1);
|
||||
assert.equal(typeof data[0].node.id, 'number');
|
||||
@@ -98,7 +98,7 @@ describe('Graph', () => {
|
||||
const graph = new Graph(client as any, 'graph'),
|
||||
[, { data }] = await Promise.all([
|
||||
await graph.query('CREATE ()-[:edge]->()'),
|
||||
await graph.roQuery('MATCH path = ()-[:edge]->() RETURN path')
|
||||
await graph.roQuery<any>('MATCH path = ()-[:edge]->() RETURN path')
|
||||
]);
|
||||
|
||||
assert.ok(Array.isArray(data));
|
||||
@@ -125,7 +125,7 @@ describe('Graph', () => {
|
||||
|
||||
testUtils.testWithClient('map', async client => {
|
||||
const graph = new Graph(client as any, 'graph'),
|
||||
{ data } = await graph.roQuery('RETURN { key: "value" } AS map');
|
||||
{ data } = await graph.query('RETURN { key: "value" } AS map');
|
||||
|
||||
assert.deepEqual(data, [{
|
||||
map: {
|
||||
@@ -136,7 +136,7 @@ describe('Graph', () => {
|
||||
|
||||
testUtils.testWithClient('point', async client => {
|
||||
const graph = new Graph(client as any, 'graph'),
|
||||
{ data } = await graph.roQuery('RETURN point({ latitude: 1, longitude: 2 }) AS point');
|
||||
{ data } = await graph.query('RETURN point({ latitude: 1, longitude: 2 }) AS point');
|
||||
|
||||
assert.deepEqual(data, [{
|
||||
point: {
|
||||
|
@@ -126,11 +126,11 @@ type GraphValue = null | string | number | boolean | Array<GraphValue> | {
|
||||
longitude: string;
|
||||
};
|
||||
|
||||
type GraphReply<T> = Omit<QueryReply, 'headers' | 'data'> & {
|
||||
export type GraphReply<T> = Omit<QueryReply, 'headers' | 'data'> & {
|
||||
data?: Array<T>;
|
||||
};
|
||||
|
||||
type GraphClientType = RedisClientType<{
|
||||
export type GraphClientType = RedisClientType<{
|
||||
graph: {
|
||||
query: typeof import('./commands/QUERY'),
|
||||
roQuery: typeof import('./commands/RO_QUERY')
|
||||
|
@@ -3,8 +3,7 @@ import RedisGraph from '.';
|
||||
|
||||
export default new TestUtils({
|
||||
dockerImageName: 'redislabs/redisgraph',
|
||||
dockerImageVersionArgument: 'redisgraph-version',
|
||||
defaultDockerVersion: '2.8.15'
|
||||
dockerImageVersionArgument: 'redisgraph-version'
|
||||
});
|
||||
|
||||
export const GLOBAL = {
|
||||
|
Reference in New Issue
Block a user