d8e0364dbb
This needs to be very well tested and discussed, as these changes can lead to private photos being accidentally published. Thank you! Signed-off-by: Michael Mayer <michael@photoprism.app>
37 lines
745 B
Go
37 lines
745 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"}
|
|
|
|
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, 0, form.Count)
|
|
})
|
|
}
|
|
|
|
func TestNewSubjectSearch(t *testing.T) {
|
|
r := NewSubjectSearch("john")
|
|
assert.IsType(t, SearchSubjects{}, r)
|
|
}
|