photoprism/internal/entity/label_fixtures_test.go

41 lines
1.1 KiB
Go
Raw Normal View History

2020-05-12 13:52:09 +02:00
package entity
import (
"testing"
2020-11-21 18:08:41 +01:00
"github.com/stretchr/testify/assert"
2020-05-12 13:52:09 +02:00
)
func TestLabelMap_Get(t *testing.T) {
t.Run("get existing label", func(t *testing.T) {
r := LabelFixtures.Get("landscape")
assert.Equal(t, "lt9k3pw1wowuy3c2", r.LabelUID)
2020-05-12 13:52:09 +02:00
assert.Equal(t, "landscape", r.LabelSlug)
assert.IsType(t, Label{}, r)
})
t.Run("get not existing label", func(t *testing.T) {
r := LabelFixtures.Get("monstera")
assert.Equal(t, "monstera", r.LabelSlug)
assert.IsType(t, Label{}, r)
})
}
func TestLabelMap_Pointer(t *testing.T) {
t.Run("get existing label pointer", func(t *testing.T) {
r := LabelFixtures.Pointer("landscape")
assert.Equal(t, "lt9k3pw1wowuy3c2", r.LabelUID)
2020-05-12 13:52:09 +02:00
assert.Equal(t, "landscape", r.LabelSlug)
assert.IsType(t, &Label{}, r)
})
t.Run("get not existing label pointer", func(t *testing.T) {
r := LabelFixtures.Pointer("monstera Leaf")
assert.Equal(t, "monstera-leaf", r.LabelSlug)
assert.IsType(t, &Label{}, r)
})
}
func TestLabelMap_PhotoLabel(t *testing.T) {
r := LabelFixtures.PhotoLabel(123, "landscape", 25, "")
assert.IsType(t, PhotoLabel{}, r)
}