mirror of
https://git.vectorsigma.ru/public/photoview.git
synced 2026-08-03 23:29:11 +00:00
* Move scanner/test_data/* to a stand-alone directory. * Include real medias. * Rename testdata to test_data * Rename test_data/scanner -> test_data/library * Clean tests to avoid depneding env. * Rename: scanner/test_data -> scanner/test_media * Rename: test_data/bin -> test_data/mock_bin * Fix paths in tests.
37 lines
774 B
Go
37 lines
774 B
Go
package scanner_utils
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/photoview/photoview/api/graphql/models"
|
|
"github.com/photoview/photoview/api/scanner/scanner_queue"
|
|
"github.com/stretchr/testify/assert"
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
func RunScannerOnUser(t *testing.T, db *gorm.DB, user *models.User) {
|
|
if !assert.NoError(t, scanner_queue.InitializeScannerQueue(db)) {
|
|
return
|
|
}
|
|
|
|
if !assert.NoError(t, scanner_queue.AddUserToQueue(user)) {
|
|
return
|
|
}
|
|
|
|
// wait for all jobs to finish
|
|
scanner_queue.CloseScannerQueue()
|
|
}
|
|
|
|
func RunScannerAll(t *testing.T, db *gorm.DB) {
|
|
if !assert.NoError(t, scanner_queue.InitializeScannerQueue(db)) {
|
|
return
|
|
}
|
|
|
|
if !assert.NoError(t, scanner_queue.AddAllToQueue()) {
|
|
return
|
|
}
|
|
|
|
// wait for all jobs to finish
|
|
scanner_queue.CloseScannerQueue()
|
|
}
|