photoprism/internal/meta/keywords_test.go

66 lines
1.2 KiB
Go
Raw Normal View History

package meta
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestData_AddKeywords(t *testing.T) {
t.Run("success", func(t *testing.T) {
data := NewData()
assert.Equal(t, "", data.Keywords.String())
data.AddKeywords("FooBar")
assert.Equal(t, "foobar", data.Keywords.String())
data.AddKeywords("BAZ; pro")
assert.Equal(t, "baz, foobar, pro", data.Keywords.String())
})
t.Run("ignore", func(t *testing.T) {
data := NewData()
assert.Equal(t, "", data.Keywords.String())
data.AddKeywords("Fo")
assert.Equal(t, "fo", data.Keywords.String())
})
}
func TestData_AutoAddKeywords(t *testing.T) {
t.Run("success", func(t *testing.T) {
data := NewData()
assert.Equal(t, "", data.Keywords.String())
data.AutoAddKeywords("FooBar burst baz flash")
assert.Equal(t, "burst", data.Keywords.String())
})
t.Run("ignore", func(t *testing.T) {
data := NewData()
assert.Equal(t, "", data.Keywords.String())
data.AutoAddKeywords("FooBar go pro baz banana")
assert.Equal(t, "", data.Keywords.String())
})
2020-10-20 10:07:27 +02:00
t.Run("ignore because too short", func(t *testing.T) {
data := NewData()
assert.Equal(t, "", data.Keywords.String())
2020-10-20 10:07:27 +02:00
data.AutoAddKeywords("es")
assert.Equal(t, "", data.Keywords.String())
2020-10-20 10:07:27 +02:00
})
}