photoprism/internal/form/search_subjects_test.go
Michael Mayer 650817a9e0 API: Add prefix to the source filename of search request handlers
Finding the right code is easier when the name matches related
functionality in other packages.
2021-11-26 14:28:50 +01:00

37 lines
753 B
Go

package form
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestSubjectSearchForm(t *testing.T) {
form := &SearchSubjects{}
assert.IsType(t, new(SearchSubjects), form)
}
func TestParseQueryStringSubject(t *testing.T) {
t.Run("Ok", func(t *testing.T) {
form := &SearchSubjects{Query: "type:person favorite:true hidden:all count:5"}
err := form.ParseQueryString()
// log.Debugf("%+v\n", form)
if err != nil {
t.Fatal("err should be nil")
}
assert.Equal(t, "person", form.Type)
assert.Equal(t, "true", form.Favorite)
assert.Equal(t, "all", form.Hidden)
assert.Equal(t, 5, form.Count)
})
}
func TestNewSubjectSearch(t *testing.T) {
r := NewSubjectSearch("john")
assert.IsType(t, SearchSubjects{}, r)
}