mirror of
https://git.vectorsigma.ru/public/photoview.git
synced 2026-08-03 18:29:17 +00:00
Fix faces not getting scanned
- This fixes #344 - Add integration tests for face recognition - Properly check that the user own the queried album
This commit is contained in:
@@ -3,9 +3,11 @@ package scanner_test
|
||||
import (
|
||||
"os"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/photoview/photoview/api/graphql/models"
|
||||
"github.com/photoview/photoview/api/scanner"
|
||||
"github.com/photoview/photoview/api/scanner/face_detection"
|
||||
"github.com/photoview/photoview/api/test_utils"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
@@ -42,6 +44,10 @@ func TestFullScan(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
if !assert.NoError(t, face_detection.InitializeFaceDetector(db)) {
|
||||
return
|
||||
}
|
||||
|
||||
if !assert.NoError(t, scanner.AddUserToQueue(user)) {
|
||||
return
|
||||
}
|
||||
@@ -54,6 +60,32 @@ func TestFullScan(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
assert.Equal(t, 10, len(all_media))
|
||||
assert.Equal(t, 9, len(all_media))
|
||||
|
||||
var all_media_url []*models.MediaURL
|
||||
if !assert.NoError(t, db.Find(&all_media_url).Error) {
|
||||
return
|
||||
}
|
||||
|
||||
assert.Equal(t, 18, len(all_media_url))
|
||||
|
||||
// Verify that faces was recognized
|
||||
assert.Eventually(t, func() bool {
|
||||
var all_face_groups []*models.FaceGroup
|
||||
if !assert.NoError(t, db.Find(&all_face_groups).Error) {
|
||||
return false
|
||||
}
|
||||
|
||||
return len(all_face_groups) == 3
|
||||
}, time.Second*5, time.Millisecond*500)
|
||||
|
||||
assert.Eventually(t, func() bool {
|
||||
var all_image_faces []*models.ImageFace
|
||||
if !assert.NoError(t, db.Find(&all_image_faces).Error) {
|
||||
return false
|
||||
}
|
||||
|
||||
return len(all_image_faces) == 6
|
||||
}, time.Second*5, time.Millisecond*500)
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user