-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhelper_test.go
108 lines (99 loc) · 2.14 KB
/
helper_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
108
package jsonpath
import (
"github.com/evilmonkeyinc/jsonpath/option"
"github.com/evilmonkeyinc/jsonpath/script"
)
type sampleData struct {
Expensive float64 `json:"expensive"`
Store *storeData `json:"store"`
}
type storeData struct {
Book []*bookData `json:"book"`
}
type bookData struct {
Author string `json:"author"`
Category string `json:"category"`
ISBN string `json:"isbn"`
Price float64 `json:"price"`
Title string `json:"title"`
}
var sampleDataObject *sampleData = &sampleData{
Expensive: 10,
Store: &storeData{
Book: []*bookData{
{
Category: "reference",
Author: "Nigel Rees",
Title: "Sayings of the Century",
Price: 8.95,
},
{
Category: "fiction",
Author: "Evelyn Waugh",
Title: "Sword of Honour",
Price: 12.99,
},
{
Category: "fiction",
Author: "Herman Melville",
Title: "Moby Dick",
ISBN: "0-553-21311-3",
Price: 8.99,
},
{
Category: "fiction",
Author: "J. R. R. Tolkien",
Title: "The Lord of the Rings",
ISBN: "0-395-19395-8",
Price: 22.99,
},
},
},
}
var sampleDataString string = `
{
"store": {
"book": [{
"category": "reference",
"author": "Nigel Rees",
"title": "Sayings of the Century",
"price": 8.95
},
{
"category": "fiction",
"author": "Evelyn Waugh",
"title": "Sword of Honour",
"price": 12.99
},
{
"category": "fiction",
"author": "Herman Melville",
"title": "Moby Dick",
"isbn": "0-553-21311-3",
"price": 8.99
},
{
"category": "fiction",
"author": "J. R. R. Tolkien",
"title": "The Lord of the Rings",
"isbn": "0-395-19395-8",
"price": 22.99
}
],
"bicycle": {
"color": "red",
"price": 19.95
}
},
"expensive": 10
}
`
type testScriptEngine struct {
value interface{}
}
func (engine *testScriptEngine) Compile(expression string, options *option.QueryOptions) (script.CompiledExpression, error) {
return nil, nil
}
func (engine *testScriptEngine) Evaluate(root, current interface{}, expression string, options *option.QueryOptions) (interface{}, error) {
return nil, nil
}