@@ -10,34 +10,41 @@ const assert = require("assert"),
10
10
deepEqual = require ( "deep-equal" ) ;
11
11
12
12
describe ( "RedisGraphAPI Test" , ( ) => {
13
- // Assuming this test is running against redis server at: localhost:6379 with no password.
13
+ // Assuming this test is running against redis server at: localhost:6379 with no password.
14
14
const api = new RedisGraph ( "social" ) ;
15
15
16
16
beforeEach ( ( ) => {
17
17
return api . deleteGraph ( ) . catch ( ( ) => { } ) ;
18
18
} ) ;
19
19
20
- it ( "test connection from port and host" , async ( ) => {
21
- // Assuming this test is running against redis server at: localhost:6379 with no password.
22
- let graph = new RedisGraph ( "social" , "127.0.0.1" , 6379 , { password :undefined } ) ;
23
- let result = await graph . query ( "CREATE ({name:'roi', age:34})" ) ;
20
+ it ( "test connection from port and host" , async ( ) => {
21
+ // Assuming this test is running against redis server at: localhost:6379 with no password.
22
+ let graph = new RedisGraph ( "social" , "127.0.0.1" , 6379 , {
23
+ password : undefined ,
24
+ } ) ;
25
+ let result = await graph . query ( "CREATE ({name:'roi', age:34})" ) ;
26
+ assert . equal ( result . size ( ) , 0 ) ;
24
27
assert . ok ( ! result . hasNext ( ) ) ;
25
- assert . equal ( 1 , result . getStatistics ( ) . nodesCreated ( ) ) ;
26
- graph . deleteGraph ( ) ;
27
- } )
28
+ assert . equal ( 1 , result . getStatistics ( ) . nodesCreated ( ) ) ;
29
+ graph . deleteGraph ( ) ;
30
+ graph . close ( ) ;
31
+ } ) ;
28
32
29
33
it ( "test connection from client" , async ( ) => {
30
- // Assuming this test is running against redis server at: localhost:6379 with no password.
31
- let graph = new RedisGraph ( "social" , redis . createClient ( ) ) ;
32
- let result = await graph . query ( "CREATE ({name:'roi', age:34})" ) ;
34
+ // Assuming this test is running against redis server at: localhost:6379 with no password.
35
+ let graph = new RedisGraph ( "social" , redis . createClient ( ) ) ;
36
+ let result = await graph . query ( "CREATE ({name:'roi', age:34})" ) ;
37
+ assert . equal ( result . size ( ) , 0 ) ;
33
38
assert . ok ( ! result . hasNext ( ) ) ;
34
- assert . equal ( 1 , result . getStatistics ( ) . nodesCreated ( ) ) ;
35
- graph . deleteGraph ( ) ;
39
+ assert . equal ( 1 , result . getStatistics ( ) . nodesCreated ( ) ) ;
40
+ graph . deleteGraph ( ) ;
41
+ graph . close ( ) ;
36
42
} ) ;
37
43
38
44
it ( "test Create Node" , async ( ) => {
39
45
// Create a node
40
46
let result = await api . query ( "CREATE ({name:'roi', age:34})" ) ;
47
+ assert . equal ( result . size ( ) , 0 ) ;
41
48
assert . ok ( ! result . hasNext ( ) ) ;
42
49
assert . equal ( 1 , result . getStatistics ( ) . nodesCreated ( ) ) ;
43
50
assert . ifError (
@@ -71,6 +78,7 @@ describe("RedisGraphAPI Test", () => {
71
78
it ( "test Create Labeled Node" , async ( ) => {
72
79
// Create a node with a label
73
80
let result = await api . query ( "CREATE (:human {name:'danny', age:12})" ) ;
81
+ assert . equal ( result . size ( ) , 0 ) ;
74
82
assert . ok ( ! result . hasNext ( ) ) ;
75
83
assert . equal (
76
84
"1" ,
@@ -97,6 +105,7 @@ describe("RedisGraphAPI Test", () => {
97
105
"MATCH (a:person {name:'roi'}), \
98
106
(b:person {name:'amit'}) CREATE (a)-[:knows]->(b)"
99
107
) ;
108
+ assert . equal ( matchResult . size ( ) , 0 ) ;
100
109
assert . ok ( ! matchResult . hasNext ( ) ) ;
101
110
assert . ifError (
102
111
matchResult . getStatistics ( ) . getStringValue ( Label . NODES_CREATED )
@@ -122,6 +131,7 @@ describe("RedisGraphAPI Test", () => {
122
131
let resultSet = await api . query (
123
132
"MATCH (r:human)-[:knows]->(a:human) RETURN r.age, r.name"
124
133
) ;
134
+ assert . equal ( resultSet . size ( ) , 1 ) ;
125
135
assert . ok ( resultSet . hasNext ( ) ) ;
126
136
assert . equal ( 0 , resultSet . getStatistics ( ) . nodesCreated ( ) ) ;
127
137
assert . equal ( 0 , resultSet . getStatistics ( ) . nodesDeleted ( ) ) ;
@@ -162,7 +172,7 @@ describe("RedisGraphAPI Test", () => {
162
172
let resultSet = await api . query (
163
173
"MATCH (a:person)-[r:knows]->(b:person) RETURN a,r"
164
174
) ;
165
-
175
+ assert . equal ( resultSet . size ( ) , 1 ) ;
166
176
assert . ok ( resultSet . hasNext ( ) ) ;
167
177
assert . equal ( 0 , resultSet . getStatistics ( ) . nodesCreated ( ) ) ;
168
178
assert . equal ( 0 , resultSet . getStatistics ( ) . nodesDeleted ( ) ) ;
@@ -199,6 +209,7 @@ describe("RedisGraphAPI Test", () => {
199
209
it ( "test null value to string" , async ( ) => {
200
210
await api . query ( "CREATE ( {nullValue:null} )" ) ;
201
211
let resultSet = await api . query ( "MATCH (n) RETURN n.nullValue" ) ;
212
+ assert . equal ( resultSet . size ( ) , 1 ) ;
202
213
assert . ok ( resultSet . hasNext ( ) ) ;
203
214
let record = resultSet . next ( ) ;
204
215
assert . equal ( undefined , record . get ( 0 ) ) ;
@@ -217,6 +228,7 @@ describe("RedisGraphAPI Test", () => {
217
228
"MATCH (a:person)-[:knows]->(:person) RETURN a"
218
229
) ;
219
230
231
+ assert . equal ( resultSet . size ( ) , 0 ) ;
220
232
assert . ok ( ! resultSet . hasNext ( ) ) ;
221
233
assert . equal ( resultSet . getHeader ( ) [ 0 ] , "a" ) ;
222
234
assert . equal ( 0 , resultSet . getStatistics ( ) . nodesCreated ( ) ) ;
@@ -236,24 +248,27 @@ describe("RedisGraphAPI Test", () => {
236
248
await api . query ( "CREATE (:person{name:'a',age:32,array:[0,1,2]})" ) ;
237
249
await api . query ( "CREATE (:person{name:'b',age:30,array:[3,4,5]})" ) ;
238
250
let resultSet = await api . query ( "WITH [0,1,2] as x return x" ) ;
251
+
252
+ assert . equal ( resultSet . size ( ) , 1 ) ;
239
253
assert . ok ( resultSet . hasNext ( ) ) ;
240
254
assert . deepStrictEqual ( [ "x" ] , resultSet . getHeader ( ) ) ;
241
255
let record = resultSet . next ( ) ;
242
256
assert . deepStrictEqual ( [ 0 , 1 , 2 ] , record . get ( 0 ) ) ;
243
257
assert . ok ( ! resultSet . hasNext ( ) ) ;
244
258
245
259
let newResultSet = await api . query ( "MATCH(n) return collect(n) as x" ) ;
260
+ assert . equal ( newResultSet . size ( ) , 1 ) ;
246
261
assert . ok ( newResultSet . hasNext ( ) ) ;
247
262
var nodeA = new Node ( "person" , {
248
263
name : "a" ,
249
264
age : 32 ,
250
- array : [ 0 , 1 , 2 ]
265
+ array : [ 0 , 1 , 2 ] ,
251
266
} ) ;
252
267
nodeA . setId ( 0 ) ;
253
268
var nodeB = new Node ( "person" , {
254
269
name : "b" ,
255
270
age : 30 ,
256
- array : [ 3 , 4 , 5 ]
271
+ array : [ 3 , 4 , 5 ] ,
257
272
} ) ;
258
273
nodeB . setId ( 1 ) ;
259
274
assert . deepStrictEqual ( [ "x" ] , newResultSet . getHeader ( ) ) ;
@@ -269,6 +284,7 @@ describe("RedisGraphAPI Test", () => {
269
284
}
270
285
let values = await Promise . all ( promises ) ;
271
286
for ( var resultSet of values ) {
287
+ assert . equal ( resultSet . size ( ) , 1 ) ;
272
288
let record = resultSet . next ( ) ;
273
289
let n = record . get ( 0 ) ;
274
290
assert . equal ( 34 , n . properties [ "age" ] ) ;
@@ -367,6 +383,7 @@ describe("RedisGraphAPI Test", () => {
367
383
. build ( ) ;
368
384
369
385
let paths = new Set ( [ path01 , path12 , path02 ] ) ;
386
+ assert . equal ( response . size ( ) , 3 ) ;
370
387
while ( response . hasNext ( ) ) {
371
388
let p = response . next ( ) . get ( "p" ) ;
372
389
let pInPaths = false ;
@@ -394,7 +411,7 @@ describe("RedisGraphAPI Test", () => {
394
411
"str" ,
395
412
[ 1 , 2 , 3 ] ,
396
413
[ "1" , "2" , "3" ] ,
397
- null
414
+ null ,
398
415
] ;
399
416
let promises = [ ] ;
400
417
for ( var i = 0 ; i < params . length ; i ++ ) {
0 commit comments