-
Notifications
You must be signed in to change notification settings - Fork 0
/
geo_radius_test.go
56 lines (46 loc) · 1.27 KB
/
geo_radius_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
package redis_qb
import "testing"
func TestGeoQuery_Default(t *testing.T) {
query := GeoQuery{
Field: "geography",
Unit: Miles,
Centre: Coord{X: 52.2341, Y: -1.052},
Radius: 10,
}
expects := "@geography:[-1.052 52.2341 10 mi]"
actual := query.QueryString()
if actual != expects {
t.Errorf("geo radius query did not match. expected '%s' but got '%s'", expects, actual)
t.Fail()
}
}
func TestGeoQuery_Optional(t *testing.T) {
query := GeoQuery{
FilterOptions: FilterOptions{Optional: true},
Field: "geography",
Unit: Miles,
Centre: Coord{X: 52.2341, Y: -1.052},
Radius: 10,
}
expects := "@geography:~[-1.052 52.2341 10 mi]"
actual := query.QueryString()
if actual != expects {
t.Errorf("geo radius query did not match. expected '%s' but got '%s'", expects, actual)
t.Fail()
}
}
func TestGeoQuery_Inverted(t *testing.T) {
query := GeoQuery{
FilterOptions: FilterOptions{Inverted: true},
Field: "geography",
Unit: Miles,
Centre: Coord{X: 52.2341, Y: -1.052},
Radius: 10,
}
expects := "@geography:-[-1.052 52.2341 10 mi]"
actual := query.QueryString()
if actual != expects {
t.Errorf("geo radius query did not match. expected '%s' but got '%s'", expects, actual)
t.Fail()
}
}