2020-01-28 22:16:59 +01:00
|
|
|
package query
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2020-05-08 15:41:01 +02:00
|
|
|
"github.com/photoprism/photoprism/internal/form"
|
|
|
|
"github.com/stretchr/testify/assert"
|
2020-01-28 22:16:59 +01:00
|
|
|
)
|
|
|
|
|
2020-05-08 15:41:01 +02:00
|
|
|
func TestGeo(t *testing.T) {
|
2020-01-28 22:16:59 +01:00
|
|
|
t.Run("search all photos", func(t *testing.T) {
|
|
|
|
query := form.NewGeoSearch("")
|
2020-05-08 15:41:01 +02:00
|
|
|
result, err := Geo(query)
|
2020-01-28 22:16:59 +01:00
|
|
|
|
|
|
|
assert.Nil(t, err)
|
|
|
|
assert.Equal(t, 4, len(result))
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("search for bridge", func(t *testing.T) {
|
|
|
|
query := form.NewGeoSearch("Query:bridge Before:3006-01-02")
|
2020-05-08 15:41:01 +02:00
|
|
|
result, err := Geo(query)
|
2020-01-28 22:16:59 +01:00
|
|
|
|
|
|
|
assert.Nil(t, err)
|
|
|
|
assert.Equal(t, "Neckarbrücke", result[0].PhotoTitle)
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("search for timeframe", func(t *testing.T) {
|
|
|
|
query := form.NewGeoSearch("After:2014-12-02 Before:3006-01-02")
|
2020-05-08 15:41:01 +02:00
|
|
|
result, err := Geo(query)
|
2020-01-28 22:16:59 +01:00
|
|
|
|
|
|
|
assert.Nil(t, err)
|
|
|
|
t.Log(result)
|
|
|
|
assert.Equal(t, "Reunion", result[0].PhotoTitle)
|
|
|
|
|
|
|
|
})
|
|
|
|
}
|