MCPcopy Create free account
hub / github.com/RedisGraph/redisgraph-go / TestMap

Function TestMap

client_test.go:239–266  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

237}
238
239func TestMap(t *testing.T) {
240 createGraph()
241
242 q := "RETURN {val_1: 5, val_2: 'str', inner: {x: [1]}}"
243 res, err := graph.Query(q)
244 if err != nil {
245 t.Error(err)
246 }
247 res.Next()
248 r := res.Record()
249 mapval := r.GetByIndex(0).(map[string]interface{})
250
251 inner_map := map[string]interface{}{"x": []interface{}{1}}
252 expected := map[string]interface{}{"val_1": 5, "val_2": "str", "inner": inner_map}
253 assert.Equal(t, mapval, expected, "expecting a map literal")
254
255 q = "MATCH (a:Country) RETURN a { .name }"
256 res, err = graph.Query(q)
257 if err != nil {
258 t.Error(err)
259 }
260 res.Next()
261 r = res.Record()
262 mapval = r.GetByIndex(0).(map[string]interface{})
263
264 expected = map[string]interface{}{"name": "Japan"}
265 assert.Equal(t, mapval, expected, "expecting a map projection")
266}
267
268func TestPath(t *testing.T) {
269 createGraph()

Callers

nothing calls this directly

Calls 5

createGraphFunction · 0.85
QueryMethod · 0.80
NextMethod · 0.80
RecordMethod · 0.80
GetByIndexMethod · 0.80

Tested by

no test coverage detected