11package batch
22
33import (
4- "testing"
5-
4+ "github.com/photoprism/photoprism/internal/entity/query"
65 "github.com/stretchr/testify/assert"
6+ "testing"
77
88 "github.com/photoprism/photoprism/internal/entity"
9- "github.com/photoprism/photoprism/internal/entity/query"
109)
1110
1211// TestApplyLabels exercises batch action logic.
@@ -1176,13 +1175,13 @@ func TestApplyLabels(t *testing.T) {
11761175 t .Error ("expected error when adding label with invalid UID, but got none" )
11771176 }
11781177 })
1179- t .Run ("RemoveNonExistingLabelByUID " , func (t * testing.T ) {
1178+ t .Run ("RemoveInvalidLabelByUID " , func (t * testing.T ) {
11801179 photo := entity .PhotoFixtures .Pointer ("Photo13" )
1181- nonExistingLabelUID := "lt9lxuqxpobbbbbb " // Non-existing UID
1180+ invalidLabelUID := "xs6sg1e1wowuy3c2 " // invalid UID
11821181
11831182 labels := Items {
11841183 Items : []Item {
1185- {Action : ActionRemove , Value : nonExistingLabelUID },
1184+ {Action : ActionRemove , Value : invalidLabelUID },
11861185 },
11871186 Action : ActionUpdate ,
11881187 }
@@ -1192,6 +1191,27 @@ func TestApplyLabels(t *testing.T) {
11921191 t .Error ("expected error when removing non-existing label, but got none" )
11931192 }
11941193 })
1194+ t .Run ("RemoveNonExistingLabelByUID" , func (t * testing.T ) {
1195+ photo := entity .PhotoFixtures .Pointer ("Photo13" )
1196+ photo .PreloadLabels ()
1197+ before := len (photo .Labels )
1198+ nonExistingLabelUID := "lt9mvj62lb9cqzoc" // Non-existing UID
1199+
1200+ labels := Items {
1201+ Items : []Item {
1202+ {Action : ActionRemove , Value : nonExistingLabelUID },
1203+ },
1204+ Action : ActionUpdate ,
1205+ }
1206+
1207+ if err := ApplyLabels (photo , labels ); err != nil {
1208+ t .Fatal (err )
1209+ }
1210+
1211+ photo .PreloadLabels ()
1212+ assert .Equal (t , before , len (photo .Labels ))
1213+
1214+ })
11951215 t .Run ("InvalidActionOnLabel" , func (t * testing.T ) {
11961216 photo := entity .PhotoFixtures .Pointer ("Photo14" )
11971217 labelUID := entity .LabelFixtures .Get ("landscape" ).LabelUID
0 commit comments