Files
photoview/api/test_utils/scanner/scanner_helpers.go
Googol Lee f1b523a27e Include a group of small but real media files for testing. (#1131)
* 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.
2024-11-23 09:02:11 +01:00

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()
}