-
Notifications
You must be signed in to change notification settings - Fork 9
/
path_test.go
38 lines (34 loc) · 1.02 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
package filter
import (
"fmt"
"testing"
)
func ExampleParsePath_attrPath() {
fmt.Println(ParsePath([]byte("members")))
fmt.Println(ParsePath([]byte("name.familyName")))
// Output:
// members <nil>
// name.familyName <nil>
}
func ExampleParsePath_valuePath() {
fmt.Println(ParsePath([]byte("members[value eq \"2819c223-7f76-453a-919d-413861904646\"]")))
fmt.Println(ParsePath([]byte("members[value eq \"2819c223-7f76-453a-919d-413861904646\"].displayName")))
// Output:
// members[value eq "2819c223-7f76-453a-919d-413861904646"] <nil>
// members[value eq "2819c223-7f76-453a-919d-413861904646"].displayName <nil>
}
func TestParsePath(t *testing.T) {
for _, example := range []string{
"members",
"name.familyName",
"addresses[type eq \"work\"]",
"members[value eq \"2819c223-7f76-453a-919d-413861904646\"]",
"members[value eq \"2819c223-7f76-453a-919d-413861904646\"].displayName",
} {
t.Run(example, func(t *testing.T) {
if _, err := ParsePath([]byte(example)); err != nil {
t.Error(err)
}
})
}
}