photoprism/internal/entity/label_fixtures_test.go
Michael Mayer 713593da4e Auth: Add CLI command to create access tokens for apps #782 #808 #3943
You can now run "photoprism auth add" to create new client access tokens
that allow external applications to use the built-in REST API.

Signed-off-by: Michael Mayer <michael@photoprism.app>
2024-01-05 16:31:07 +01:00

40 lines
1.1 KiB
Go

package entity
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestLabelMap_Get(t *testing.T) {
t.Run("get existing label", func(t *testing.T) {
r := LabelFixtures.Get("landscape")
assert.Equal(t, "ls6sg6b1wowuy3c2", r.LabelUID)
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, "ls6sg6b1wowuy3c2", r.LabelUID)
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)
}