API: Ensure slugs are not empty before saving/creating labels #4761

Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
Michael Mayer
2025-02-04 03:35:01 +01:00
parent 5d0d1729b7
commit c60c0ce3a6
9 changed files with 105 additions and 27 deletions

View File

@@ -44,7 +44,6 @@ func TestLabel_SetName(t *testing.T) {
assert.Equal(t, "landscape", entity.LabelSlug)
assert.Equal(t, "landschaft", entity.CustomSlug)
})
t.Run("new name empty", func(t *testing.T) {
entity := LabelFixtures["flower"]
@@ -52,7 +51,7 @@ func TestLabel_SetName(t *testing.T) {
assert.Equal(t, "flower", entity.LabelSlug)
assert.Equal(t, "flower", entity.CustomSlug)
entity.SetName("")
assert.False(t, entity.SetName(""))
assert.Equal(t, "Flower", entity.LabelName)
assert.Equal(t, "flower", entity.LabelSlug)