mirror of
https://github.com/photoprism/photoprism.git
synced 2025-12-12 00:34:13 +01:00
These changes also auto assign labels based on the generated captions. Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
@@ -38,3 +38,54 @@ func TestFindLabel(t *testing.T) {
|
||||
assert.NotNil(t, result)
|
||||
})
|
||||
}
|
||||
|
||||
func TestFindPhotoLabel(t *testing.T) {
|
||||
t.Run("Success", func(t *testing.T) {
|
||||
if err := WarmPhotoLabelCache(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// See PhotoFixtures and LabelFixtures for test data.
|
||||
m := &PhotoLabel{PhotoID: 1000000, LabelID: 1000001}
|
||||
|
||||
cached, err := FindPhotoLabel(m.PhotoID, m.LabelID, true)
|
||||
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, m.LabelID, cached.LabelID)
|
||||
assert.Equal(t, m.PhotoID, cached.PhotoID)
|
||||
assert.Equal(t, SrcImage, cached.LabelSrc)
|
||||
assert.Equal(t, 38, cached.Uncertainty)
|
||||
|
||||
FlushPhotoLabelCache()
|
||||
|
||||
cached, err = FindPhotoLabel(m.PhotoID, m.LabelID, true)
|
||||
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, m.LabelID, cached.LabelID)
|
||||
assert.Equal(t, m.PhotoID, cached.PhotoID)
|
||||
assert.Equal(t, SrcImage, cached.LabelSrc)
|
||||
assert.Equal(t, 38, cached.Uncertainty)
|
||||
})
|
||||
t.Run("NotFound", func(t *testing.T) {
|
||||
result, err := FindPhotoLabel(1, 99999999, true)
|
||||
assert.Error(t, err)
|
||||
assert.NotNil(t, result)
|
||||
result, err = FindPhotoLabel(1, 99999999, false)
|
||||
assert.Error(t, err)
|
||||
assert.NotNil(t, result)
|
||||
result, err = FindPhotoLabel(1, 99999999, true)
|
||||
assert.Error(t, err)
|
||||
assert.NotNil(t, result)
|
||||
})
|
||||
t.Run("InvalidID", func(t *testing.T) {
|
||||
result, err := FindPhotoLabel(0, 0, true)
|
||||
assert.Error(t, err)
|
||||
assert.NotNil(t, result)
|
||||
result, err = FindPhotoLabel(0, 0, false)
|
||||
assert.Error(t, err)
|
||||
assert.NotNil(t, result)
|
||||
result, err = FindPhotoLabel(0, 0, true)
|
||||
assert.Error(t, err)
|
||||
assert.NotNil(t, result)
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user