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

Function TestCreateQuery

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

Source from the content-addressed store, hash-verified

109}
110
111func TestCreateQuery(t *testing.T) {
112 q := "CREATE (w:WorkPlace {name:'RedisLabs'})"
113 res, err := graph.Query(q)
114 if err != nil {
115 t.Error(err)
116 }
117
118 assert.True(t, res.Empty(), "Expecting empty result-set")
119
120 // Validate statistics.
121 assert.Equal(t, res.NodesCreated(), 1, "Expecting a single node to be created.")
122 assert.Equal(t, res.PropertiesSet(), 1, "Expecting a songle property to be added.")
123
124 q = "MATCH (w:WorkPlace) RETURN w"
125 res, err = graph.Query(q)
126 if err != nil {
127 t.Error(err)
128 }
129
130 assert.False(t, res.Empty(), "Expecting resultset to include a single node.")
131 res.Next()
132 r := res.Record()
133 w := r.GetByIndex(0).(*Node)
134 assert.Equal(t, w.Label, "WorkPlace", "Unexpected node label.")
135}
136
137func TestCreateROQueryFailure(t *testing.T) {
138 q := "CREATE (w:WorkPlace {name:'RedisLabs'})"

Callers

nothing calls this directly

Calls 7

QueryMethod · 0.80
EmptyMethod · 0.80
NodesCreatedMethod · 0.80
PropertiesSetMethod · 0.80
NextMethod · 0.80
RecordMethod · 0.80
GetByIndexMethod · 0.80

Tested by

no test coverage detected