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

Function checkQueryResults

client_test.go:81–109  ·  view source on GitHub ↗
(t *testing.T, res *QueryResult)

Source from the content-addressed store, hash-verified

79}
80
81func checkQueryResults(t *testing.T, res *QueryResult) {
82 assert.Equal(t, len(res.results), 1, "expecting 1 result record")
83
84 res.Next()
85 r := res.Record()
86
87 s, ok := r.GetByIndex(0).(*Node)
88 assert.True(t, ok, "First column should contain nodes.")
89 e, ok := r.GetByIndex(1).(*Edge)
90 assert.True(t, ok, "Second column should contain edges.")
91 d, ok := r.GetByIndex(2).(*Node)
92 assert.True(t, ok, "Third column should contain nodes.")
93
94 assert.Equal(t, s.Label, "Person", "Node should be of type 'Person'")
95 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'")
97
98 assert.Equal(t, len(s.Properties), 4, "Person node should have 4 properties")
99
100 assert.Equal(t, s.GetProperty("name"), "John Doe", "Unexpected property value.")
101 assert.Equal(t, s.GetProperty("age"), 33, "Unexpected property value.")
102 assert.Equal(t, s.GetProperty("gender"), "male", "Unexpected property value.")
103 assert.Equal(t, s.GetProperty("status"), "single", "Unexpected property value.")
104
105 assert.Equal(t, e.GetProperty("year"), 2017, "Unexpected property value.")
106
107 assert.Equal(t, d.GetProperty("name"), "Japan", "Unexpected property value.")
108 assert.Equal(t, d.GetProperty("population"), 126800000, "Unexpected property value.")
109}
110
111func TestCreateQuery(t *testing.T) {
112 q := "CREATE (w:WorkPlace {name:'RedisLabs'})"

Callers 2

TestMatchQueryFunction · 0.85
TestMatchROQueryFunction · 0.85

Calls 4

NextMethod · 0.80
RecordMethod · 0.80
GetByIndexMethod · 0.80
GetPropertyMethod · 0.45

Tested by

no test coverage detected