This repository has been archived by the owner on Dec 12, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathpath_test.go
107 lines (96 loc) · 2.37 KB
/
path_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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
package go_cypherdsl
import (
"github.com/stretchr/testify/require"
"testing"
)
func TestMatchBuilder(t *testing.T) {
req := require.New(t)
//(a)
cypher, err := NewPath().V(V{Name: "a"}).ToCypher()
req.Nil(err)
req.EqualValues("(a)", cypher)
//(a)--(b)
cypher, err = NewPath().
V(V{Name: "a"}).
E(E{Direction: DirectionNone}).
V(V{Name: "b"}).
ToCypher()
req.Nil(err)
req.EqualValues("(a)--(b)", cypher)
//(a:type)--(b:type)
cypher, err = NewPath().
V(V{Name: "a", Type: "type"}).
E(E{Direction: DirectionNone}).
V(V{Name: "b", Type: "type"}).
ToCypher()
req.Nil(err)
req.EqualValues("(a:type)--(b:type)", cypher)
//(a:type)-[e:type]->(b:type)
cypher, err = NewPath().
V(V{Name: "a", Type: "type"}).
E(E{Direction: DirectionOutgoing, Name: "e", Types: []string{"type"}}).
V(V{Name: "b", Type: "type"}).
ToCypher()
req.Nil(err)
req.EqualValues("(a:type)-[e:type]->(b:type)", cypher)
//p=(a:type),(b:type)--(c:type)
cypher, err = NewPath().
P().
V(V{Name: "a", Type: "type"}, V{Name: "b", Type: "type"}).
E(E{Direction: DirectionNone}).
V(V{Name: "c", Type: "type"}).
ToCypher()
req.Nil(err)
req.EqualValues("p=(a:type),(b:type)--(c:type)", cypher)
//p=(a:type)-[e:type]->(b:type)
cypher, err = NewPath().
P().
V(V{Name: "a", Type: "type"}).
E(E{Direction: DirectionOutgoing, Name: "e", Types: []string{"type"}}).
V(V{Name: "b", Type: "type"}).
ToCypher()
req.Nil(err)
req.EqualValues("p=(a:type)-[e:type]->(b:type)", cypher)
//(a)--(b)-[e:type*2..5 ]->(c:type{q:1})
params, err := ParamsFromMap(map[string]interface{}{
"q": 1,
})
req.Nil(err)
cypher, err = NewPath().
V(V{Name: "a"}).
E(E{Direction: DirectionNone}).
V(V{Name: "b"}).
E(E{
Name: "e",
Types: []string{"type"},
Direction: DirectionOutgoing,
MaxJumps: 5,
MinJumps: 2,
}).
V(V{
Name: "c",
Type: "type",
Params: params,
}).ToCypher()
req.Nil(err)
req.EqualValues("(a)--(b)-[e:type*2..5]->(c:type{q:1})", cypher)
//p=(a)--()-[e:type*0..5]->(c:type {q:1})
cypher, err = NewPath().
P().
V(V{Name: "a"}).
E(E{Direction: DirectionNone}).
V(V{}).
E(E{
Name: "e",
Types: []string{"type"},
Direction: DirectionOutgoing,
MaxJumps: 5,
}).
V(V{
Name: "c",
Type: "type",
Params: params,
}).ToCypher()
req.Nil(err)
req.EqualValues("p=(a)--()-[e:type*0..5]->(c:type{q:1})", cypher)
}