-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Expand file tree
/
Copy pathdql_test.go
More file actions
95 lines (89 loc) · 1.34 KB
/
dql_test.go
File metadata and controls
95 lines (89 loc) · 1.34 KB
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
/*
* SPDX-FileCopyrightText: © Hypermode Inc. <[email protected]>
* SPDX-License-Identifier: Apache-2.0
*/
package dql
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestParseDQL(t *testing.T) {
testCases := []string{
`{ set {_:a <name> "Alice" .}}`,
"schema{}",
`upsert {
query {
ns(func: eq(dgraph.namespace.name, "ns1")) {
q as var
dgraph.namespace.id
}
}
mutation {
delete {
uid(q) * * .
}
}
}`,
`{
q(func: eq(dgraph.namespace.name, "ns1")) {
uid
dgraph.type
dgraph.namespace.id
}
}`,
` query test($a: int) {
q(func: uid(0x1)) {
x as count(uid)
p : math(x + $a)
}
}`,
`{
me(func: uid(1)) {
Upvote {
u as Author
}
count(val(u))
}
}`,
`{
user(func: uid(0x0a)) {
...fragmenta,...fragmentb
friends {
name
}
...fragmentc
hobbies
...fragmentd
}
me(func: uid(0x01)) {
...fragmenta
...fragmentb
}
}
fragment fragmenta {
name
}
fragment fragmentb {
id
}
fragment fragmentc {
name
}
fragment fragmentd {
id
}`,
`{
set {
<name> <is> <something> .
<hometown> <is> <san/francisco> .
}
delete {
<name> <is> <something-else> .
}
}`,
}
for _, tc := range testCases {
_, err := ParseDQL(tc)
require.NoError(t, err)
}
}