2020-01-15 04:04:33 +01:00
|
|
|
package form
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
|
|
|
|
log "github.com/sirupsen/logrus"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestGeoSearch(t *testing.T) {
|
|
|
|
t.Run("valid query", func(t *testing.T) {
|
|
|
|
form := &GeoSearch{Query: "query:\"fooBar baz\" before:2019-01-15 dist:25000 lat:33.45343166666667"}
|
|
|
|
|
|
|
|
err := form.ParseQueryString()
|
|
|
|
|
2020-01-31 15:29:06 +01:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal("err should be nil")
|
|
|
|
}
|
|
|
|
|
2020-01-15 04:04:33 +01:00
|
|
|
log.Debugf("%+v\n", form)
|
|
|
|
|
|
|
|
assert.Equal(t, "foobar baz", form.Query)
|
|
|
|
assert.Equal(t, time.Date(2019, 01, 15, 0, 0, 0, 0, time.UTC), form.Before)
|
|
|
|
assert.Equal(t, uint(0x61a8), form.Dist)
|
2020-04-26 11:41:54 +02:00
|
|
|
assert.Equal(t, float32(33.45343), form.Lat)
|
2020-01-15 04:04:33 +01:00
|
|
|
})
|
|
|
|
}
|
2020-05-06 17:05:06 +02:00
|
|
|
|
|
|
|
func TestNewGeoSearch(t *testing.T) {
|
|
|
|
r := NewGeoSearch("Berlin")
|
|
|
|
assert.IsType(t, GeoSearch{}, r)
|
|
|
|
}
|