-
Notifications
You must be signed in to change notification settings - Fork 9
/
cypher_test.go
62 lines (52 loc) · 1.07 KB
/
cypher_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package neo4j
import (
"fmt"
"testing"
)
func TestSendCypherQuery(t *testing.T) {
neo4jConnection := Connect("")
node := &Node{}
node2 := &Node{}
batchNode := neo4jConnection.NewBatch()
batchNode.Create(node)
batchNode.Create(node2)
_, err := batchNode.Execute()
if err != nil {
t.Error(err)
}
cypher := &Cypher{
Query: map[string]string{
"query": fmt.Sprintf(`
START k=node(%v, %v)
return id(k) as eventNodeId
`, node.ID, node2.ID),
},
Payload: map[string]interface{}{},
}
batch := neo4jConnection.NewBatch()
batch.Create(cypher)
_, err = batch.Execute()
if err != nil {
t.Error(err)
}
if cypher.Payload.(map[string]interface{})["data"] == nil {
t.Error("no data")
}
}
func TestSendCypherQueryWithNoResults(t *testing.T) {
neo4jConnection := Connect("")
cypher := &Cypher{
Query: map[string]string{
"query": fmt.Sprintf(`
START k=node(%v)
return k
`),
},
}
batch := neo4jConnection.NewBatch()
batch.Create(cypher)
batch.Execute()
if cypher.Payload != nil {
t.Error("Got cypher results")
}
}