Fix: unittests
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
package repos
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log/slog"
|
||||
"os"
|
||||
|
||||
@ -12,11 +13,11 @@ type AllRepos interface {
|
||||
RoomsRepo
|
||||
ActionsRepo
|
||||
PlayersRepo
|
||||
SessionsRepo
|
||||
}
|
||||
|
||||
type RepoProvider struct {
|
||||
DB *sqlx.DB
|
||||
Ext sqlx.Ext
|
||||
DB *sqlx.DB
|
||||
}
|
||||
|
||||
func NewRepoProvider(pathToDB string) *RepoProvider {
|
||||
@ -30,3 +31,11 @@ func NewRepoProvider(pathToDB string) *RepoProvider {
|
||||
DB: db,
|
||||
}
|
||||
}
|
||||
|
||||
func getDB(ctx context.Context, db *sqlx.DB) sqlx.ExtContext {
|
||||
if tx, ok := ctx.Value("tx").(*sqlx.Tx);
|
||||
ok {
|
||||
return tx
|
||||
}
|
||||
return db
|
||||
}
|
||||
|
Reference in New Issue
Block a user