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