2019-05-03 18:57:28 +02:00
|
|
|
package forms
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
2019-05-15 23:07:25 +02:00
|
|
|
"time"
|
2019-05-03 18:57:28 +02:00
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
2019-05-15 21:51:00 +02:00
|
|
|
|
|
|
|
log "github.com/sirupsen/logrus"
|
2019-05-03 18:57:28 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestPhotoSearchForm(t *testing.T) {
|
|
|
|
form := &PhotoSearchForm{}
|
|
|
|
|
|
|
|
assert.IsType(t, new(PhotoSearchForm), form)
|
|
|
|
}
|
2019-05-15 21:51:00 +02:00
|
|
|
|
|
|
|
func TestParseQueryString(t *testing.T) {
|
2019-06-04 18:26:35 +02:00
|
|
|
form := &PhotoSearchForm{Query: "label:cat query:\"fooBar baz\" before:2019-01-15 camera:23"}
|
2019-05-15 21:51:00 +02:00
|
|
|
|
|
|
|
err := form.ParseQueryString()
|
|
|
|
|
|
|
|
log.Debugf("%+v\n", form)
|
|
|
|
|
|
|
|
assert.Nil(t, err)
|
2019-06-04 18:26:35 +02:00
|
|
|
assert.Equal(t, "cat", form.Label)
|
2019-05-15 21:51:00 +02:00
|
|
|
assert.Equal(t, "foobar baz", form.Query)
|
2019-05-15 23:07:25 +02:00
|
|
|
assert.Equal(t, 23, form.Camera)
|
|
|
|
assert.Equal(t, time.Date(2019, 01, 15, 0, 0, 0, 0, time.UTC), form.Before)
|
2019-05-15 21:51:00 +02:00
|
|
|
}
|