1
Fork 0
photoview/api/test_utils/scanner_helpers.go

37 lines
771 B
Go
Raw Normal View History

2021-11-06 12:23:47 +01:00
package test_utils
import (
"testing"
"github.com/photoview/photoview/api/graphql/models"
2022-03-28 18:43:00 +02:00
"github.com/photoview/photoview/api/scanner/scanner_queue"
2021-11-06 12:23:47 +01:00
"github.com/stretchr/testify/assert"
"gorm.io/gorm"
)
func RunScannerOnUser(t *testing.T, db *gorm.DB, user *models.User) {
2022-03-28 18:43:00 +02:00
if !assert.NoError(t, scanner_queue.InitializeScannerQueue(db)) {
2021-11-06 12:23:47 +01:00
return
}
2022-03-28 18:43:00 +02:00
if !assert.NoError(t, scanner_queue.AddUserToQueue(user)) {
2021-11-06 12:23:47 +01:00
return
}
// wait for all jobs to finish
2022-03-28 18:43:00 +02:00
scanner_queue.CloseScannerQueue()
2021-11-06 12:23:47 +01:00
}
func RunScannerAll(t *testing.T, db *gorm.DB) {
2022-03-28 18:43:00 +02:00
if !assert.NoError(t, scanner_queue.InitializeScannerQueue(db)) {
2021-11-06 12:23:47 +01:00
return
}
2022-03-28 18:43:00 +02:00
if !assert.NoError(t, scanner_queue.AddAllToQueue()) {
2021-11-06 12:23:47 +01:00
return
}
// wait for all jobs to finish
2022-03-28 18:43:00 +02:00
scanner_queue.CloseScannerQueue()
2021-11-06 12:23:47 +01:00
}