@@ -216,6 +216,35 @@ func TestArray(t *testing.T) {
216
216
assert .Equal (t , b .GetProperty ("array" ), resB .GetProperty ("array" ), "Unexpected property value." )
217
217
}
218
218
219
+ func TestMap (t * testing.T ) {
220
+ createGraph ()
221
+
222
+ q := "RETURN {val_1: 5, val_2: 'str', inner: {x: [1]}}"
223
+ res , err := graph .Query (q )
224
+ if err != nil {
225
+ t .Error (err )
226
+ }
227
+ res .Next ()
228
+ r := res .Record ()
229
+ mapval := r .GetByIndex (0 ).(map [string ]interface {})
230
+
231
+ inner_map := map [string ]interface {}{"x" : []interface {}{1 }}
232
+ expected := map [string ]interface {}{"val_1" : 5 , "val_2" : "str" , "inner" : inner_map }
233
+ assert .Equal (t , mapval , expected , "expecting a map literal" )
234
+
235
+ q = "MATCH (a:Country) RETURN a { .name }"
236
+ res , err = graph .Query (q )
237
+ if err != nil {
238
+ t .Error (err )
239
+ }
240
+ res .Next ()
241
+ r = res .Record ()
242
+ mapval = r .GetByIndex (0 ).(map [string ]interface {})
243
+
244
+ expected = map [string ]interface {}{"name" : "Japan" }
245
+ assert .Equal (t , mapval , expected , "expecting a map projection" )
246
+ }
247
+
219
248
func TestPath (t * testing.T ) {
220
249
createGraph ()
221
250
q := "MATCH p = (:Person)-[:Visited]->(:Country) RETURN p"
@@ -228,7 +257,7 @@ func TestPath(t *testing.T) {
228
257
229
258
res .Next ()
230
259
r := res .Record ()
231
-
260
+
232
261
p , ok := r .GetByIndex (0 ).(Path )
233
262
assert .True (t , ok , "First column should contain path." )
234
263
0 commit comments