@@ -16,8 +16,8 @@ func createGraph() {
1616 graph = GraphNew ("social" , conn )
1717
1818 // Create 2 nodes connect via a single edge.
19- japan := NodeNew ("Country" , "j" , nil )
20- john := NodeNew ("Person" , "p" , nil )
19+ japan := NodeNew ([] string { "Country" } , "j" , nil )
20+ john := NodeNew ([] string { "Person" } , "p" , nil )
2121 edge := EdgeNew ("Visited" , john , japan , nil )
2222
2323 // Set node properties.
@@ -91,9 +91,9 @@ func checkQueryResults(t *testing.T, res *QueryResult) {
9191 d , ok := r .GetByIndex (2 ).(* Node )
9292 assert .True (t , ok , "Third column should contain nodes." )
9393
94- assert .Equal (t , s .Label , "Person" , "Node should be of type 'Person'" )
94+ assert .Equal (t , s .Labels [ 0 ] , "Person" , "Node should be of type 'Person'" )
9595 assert .Equal (t , e .Relation , "Visited" , "Edge should be of relation type 'Visited'" )
96- assert .Equal (t , d .Label , "Country" , "Node should be of type 'Country'" )
96+ assert .Equal (t , d .Labels [ 0 ] , "Country" , "Node should be of type 'Country'" )
9797
9898 assert .Equal (t , len (s .Properties ), 4 , "Person node should have 4 properties" )
9999
@@ -131,7 +131,7 @@ func TestCreateQuery(t *testing.T) {
131131 res .Next ()
132132 r := res .Record ()
133133 w := r .GetByIndex (0 ).(* Node )
134- assert .Equal (t , w .Label , "WorkPlace" , "Unexpected node label." )
134+ assert .Equal (t , w .Labels [ 0 ] , "WorkPlace" , "Unexpected node label." )
135135}
136136
137137func TestCreateROQueryFailure (t * testing.T ) {
@@ -199,8 +199,8 @@ func TestArray(t *testing.T) {
199199 t .Error (err )
200200 }
201201
202- a := NodeNew ("person" , "" , nil )
203- b := NodeNew ("person" , "" , nil )
202+ a := NodeNew ([] string { "person" } , "" , nil )
203+ b := NodeNew ([] string { "person" } , "" , nil )
204204
205205 a .SetProperty ("name" , "a" )
206206 a .SetProperty ("age" , 32 )
@@ -288,9 +288,9 @@ func TestPath(t *testing.T) {
288288 e := p .GetEdge (0 )
289289 d := p .LastNode ()
290290
291- assert .Equal (t , s .Label , "Person" , "Node should be of type 'Person'" )
291+ assert .Equal (t , s .Labels [ 0 ] , "Person" , "Node should be of type 'Person'" )
292292 assert .Equal (t , e .Relation , "Visited" , "Edge should be of relation type 'Visited'" )
293- assert .Equal (t , d .Label , "Country" , "Node should be of type 'Country'" )
293+ assert .Equal (t , d .Labels [ 0 ] , "Country" , "Node should be of type 'Country'" )
294294
295295 assert .Equal (t , len (s .Properties ), 4 , "Person node should have 4 properties" )
296296
@@ -308,12 +308,12 @@ func TestPath(t *testing.T) {
308308
309309func TestParameterizedQuery (t * testing.T ) {
310310 createGraph ()
311- params := []interface {}{1 , 2.3 , "str" , true , false , nil , []interface {}{0 , 1 , 2 }, []interface {}{"0" , "1" , "2" }}
311+ params := []interface {}{1 , 2.3 , "str" , true , false , nil , []interface {}{0 , 1 , 2 }, []interface {}{"0" , "1" , "2" }}
312312 q := "RETURN $param"
313313 params_map := make (map [string ]interface {})
314314 for index , param := range params {
315315 params_map ["param" ] = param
316- res , err := graph .ParameterizedQuery (q , params_map );
316+ res , err := graph .ParameterizedQuery (q , params_map )
317317 if err != nil {
318318 t .Error (err )
319319 }
@@ -348,24 +348,24 @@ func TestCreateIndex(t *testing.T) {
348348func TestQueryStatistics (t * testing.T ) {
349349 graph .Flush ()
350350 err := graph .Delete ()
351- assert .Nil (t ,err )
351+ assert .Nil (t , err )
352352
353353 q := "CREATE (:Person{name:'a',age:32,array:[0,1,2]})"
354354 res , err := graph .Query (q )
355- assert .Nil (t ,err )
355+ assert .Nil (t , err )
356356
357357 assert .Equal (t , 1 , res .NodesCreated (), "Expecting 1 node created" )
358358 assert .Equal (t , 0 , res .NodesDeleted (), "Expecting 0 nodes deleted" )
359- assert .Greater (t , res .InternalExecutionTime (),0.0 , "Expecting internal execution time not to be 0.0" )
359+ assert .Greater (t , res .InternalExecutionTime (), 0.0 , "Expecting internal execution time not to be 0.0" )
360360 assert .Equal (t , true , res .Empty (), "Expecting empty resultset" )
361361
362- res ,err = graph .Query ("MATCH (n) DELETE n" )
363- assert .Nil (t ,err )
362+ res , err = graph .Query ("MATCH (n) DELETE n" )
363+ assert .Nil (t , err )
364364 assert .Equal (t , 1 , res .NodesDeleted (), "Expecting 1 nodes deleted" )
365365
366366 // Create 2 nodes connect via a single edge.
367- japan := NodeNew ("Country" , "j" , nil )
368- john := NodeNew ("Person" , "p" , nil )
367+ japan := NodeNew ([] string { "Country" } , "j" , nil )
368+ john := NodeNew ([] string { "Person" } , "p" , nil )
369369 edge := EdgeNew ("Visited" , john , japan , nil )
370370
371371 // Set node properties.
@@ -386,21 +386,21 @@ func TestQueryStatistics(t *testing.T) {
386386
387387 // Flush graph to DB.
388388 res , err = graph .Commit ()
389- assert .Nil (t ,err )
389+ assert .Nil (t , err )
390390 assert .Equal (t , 2 , res .NodesCreated (), "Expecting 2 node created" )
391391 assert .Equal (t , 0 , res .NodesDeleted (), "Expecting 0 nodes deleted" )
392392 assert .Equal (t , 7 , res .PropertiesSet (), "Expecting 7 properties set" )
393393 assert .Equal (t , 1 , res .RelationshipsCreated (), "Expecting 1 relationships created" )
394394 assert .Equal (t , 0 , res .RelationshipsDeleted (), "Expecting 0 relationships deleted" )
395- assert .Greater (t , res .InternalExecutionTime (),0.0 , "Expecting internal execution time not to be 0.0" )
395+ assert .Greater (t , res .InternalExecutionTime (), 0.0 , "Expecting internal execution time not to be 0.0" )
396396 assert .Equal (t , true , res .Empty (), "Expecting empty resultset" )
397397 q = "MATCH p = (:Person)-[:Visited]->(:Country) RETURN p"
398398 res , err = graph .Query (q )
399- assert .Nil (t ,err )
399+ assert .Nil (t , err )
400400 assert .Equal (t , len (res .results ), 1 , "expecting 1 result record" )
401401 assert .Equal (t , false , res .Empty (), "Expecting resultset to have records" )
402- res ,err = graph .Query ("MATCH ()-[r]-() DELETE r" )
403- assert .Nil (t ,err )
402+ res , err = graph .Query ("MATCH ()-[r]-() DELETE r" )
403+ assert .Nil (t , err )
404404 assert .Equal (t , 1 , res .RelationshipsDeleted (), "Expecting 1 relationships deleted" )
405405}
406406
@@ -410,39 +410,65 @@ func TestUtils(t *testing.T) {
410410
411411 res = ToString ("test_string" )
412412 assert .Equal (t , res , "\" test_string\" " )
413-
413+
414414 res = ToString (10 )
415- assert .Equal (t , res , "10" )
415+ assert .Equal (t , res , "10" )
416416
417417 res = ToString (1.2 )
418418 assert .Equal (t , res , "1.2" )
419419
420420 res = ToString (true )
421421 assert .Equal (t , res , "true" )
422422
423- var arr = []interface {}{1 ,2 , 3 , "boom" }
423+ var arr = []interface {}{1 , 2 , 3 , "boom" }
424424 res = ToString (arr )
425425 assert .Equal (t , res , "[1,2,3,\" boom\" ]" )
426-
426+
427427 jsonMap := make (map [string ]interface {})
428- jsonMap ["object" ] = map [string ]interface {} {"foo" : 1 }
428+ jsonMap ["object" ] = map [string ]interface {}{"foo" : 1 }
429429 res = ToString (jsonMap )
430430 assert .Equal (t , res , "{object: {foo: 1}}" )
431431}
432432
433+ func TestMultiLabelNode (t * testing.T ) {
434+ // clear database
435+ graph .Flush ()
436+ err := graph .Delete ()
437+ assert .Nil (t , err )
438+
439+ // create a multi label node
440+ multiLabelNode := NodeNew ([]string {"A" ,"B" }, "n" , nil )
441+ graph .AddNode (multiLabelNode )
442+ _ , err = graph .Commit ()
443+ assert .Nil (t , err )
444+
445+ // fetch node
446+ res , err := graph .Query ("MATCH (n) RETURN n" )
447+ assert .Nil (t , err )
448+
449+ res .Next ()
450+ r := res .Record ()
451+ n := r .GetByIndex (0 ).(* Node )
452+
453+ // expecting 2 labels
454+ assert .Equal (t , len (n .Labels ), 2 , "expecting 2 labels" )
455+ assert .Equal (t , n .Labels [0 ], "A" )
456+ assert .Equal (t , n .Labels [1 ], "B" )
457+ }
458+
433459func TestNodeMapDatatype (t * testing.T ) {
434460 graph .Flush ()
435461 err := graph .Delete ()
436462 assert .Nil (t , err )
437463
438464 // Create 2 nodes connect via a single edge.
439- japan := NodeNew ("Country" , "j" ,
465+ japan := NodeNew ([] string { "Country" } , "j" ,
440466 map [string ]interface {}{
441467 "name" : "Japan" ,
442468 "population" : 126800000 ,
443469 "states" : []string {"Kanto" , "Chugoku" },
444470 })
445- john := NodeNew ("Person" , "p" ,
471+ john := NodeNew ([] string { "Person" } , "p" ,
446472 map [string ]interface {}{
447473 "name" : "John Doe" ,
448474 "age" : 33 ,
@@ -488,7 +514,7 @@ func TestTimeout(t *testing.T) {
488514
489515 params := make (map [string ]interface {})
490516 params ["ub" ] = 1000000
491- res , err = graph .ParameterizedQueryWithOptions ("UNWIND range(0, $ub) AS v RETURN v" , params , options );
517+ res , err = graph .ParameterizedQueryWithOptions ("UNWIND range(0, $ub) AS v RETURN v" , params , options )
492518 assert .Nil (t , res )
493519 assert .NotNil (t , err )
494520}
0 commit comments