Enha: create tx; cardword test

This commit is contained in:
Grail Finder
2025-07-04 07:00:16 +03:00
parent c9196d3202
commit 8b81e2e2c4
3 changed files with 553 additions and 1 deletions

View File

@ -17,6 +17,7 @@ type AllRepos interface {
PlayersRepo
SessionsRepo
WordCardsRepo
InitTx(ctx context.Context) (context.Context, *sqlx.Tx, error)
}
type RepoProvider struct {
@ -95,3 +96,11 @@ func getDB(ctx context.Context, db *sqlx.DB) sqlx.ExtContext {
}
return db
}
func (p *RepoProvider) InitTx(ctx context.Context) (context.Context, *sqlx.Tx, error) {
tx, err := p.DB.BeginTxx(ctx, nil)
if err != nil {
return nil, nil, err
}
return context.WithValue(ctx, "tx", tx), tx, nil
}