mirror of
https://git.vectorsigma.ru/public/photoview.git
synced 2026-08-03 22:19:07 +00:00
Fix API tests
This commit is contained in:
@@ -3,6 +3,7 @@ package scanner_task
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"flag"
|
||||
"io/fs"
|
||||
|
||||
"github.com/photoview/photoview/api/graphql/models"
|
||||
@@ -84,6 +85,11 @@ func (c TaskContext) Value(key interface{}) interface{} {
|
||||
}
|
||||
|
||||
func (c TaskContext) WithDB(db *gorm.DB) TaskContext {
|
||||
// Allow db to be nil in tests
|
||||
if db == nil && flag.Lookup("test.v") != nil {
|
||||
return c
|
||||
}
|
||||
|
||||
return c.WithValue(taskCtxKeyDatabase, db.WithContext(c.ctx))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user