@@ -6,15 +6,25 @@ import (
6
6
"testing"
7
7
"time"
8
8
9
+ "github.com/jackc/pgx/v5"
9
10
"github.com/stretchr/testify/assert"
10
- "go.inout.gg/shield/db/driverpgxv5"
11
11
"go.inout.gg/foundations/must"
12
- "go.inout.gg/foundations/sql/db/dbtest"
12
+ "go.inout.gg/foundations/sqldb/sqldbtest"
13
+ "go.inout.gg/shield/db/driverpgxv5"
14
+ "go.inout.gg/shield/shieldmigrate"
13
15
)
14
16
17
+ var migrator = shieldmigrate .New ()
18
+
19
+ func makeDB (ctx context.Context , t * testing.T ) * sqldbtest.DB {
20
+ return sqldbtest .Must (ctx , t , sqldbtest .WithUp (func (ctx context.Context , conn * pgx.Conn ) error {
21
+ return migrator .Up (ctx , conn , nil )
22
+ }))
23
+ }
24
+
15
25
func TestUserRegistration (t * testing.T ) {
16
26
ctx := context .Background ()
17
- db := dbtest . Must (ctx , t )
27
+ db := makeDB (ctx , t )
18
28
logger := slog .Default ()
19
29
config := & Config [any ]{
20
30
PasswordHasher : DefaultPasswordHasher ,
@@ -76,7 +86,7 @@ func TestUserRegistration(t *testing.T) {
76
86
77
87
func TestUserLogin (t * testing.T ) {
78
88
ctx := context .Background ()
79
- db := dbtest . Must (ctx , t )
89
+ db := makeDB (ctx , t )
80
90
81
91
t .Run ("user not found" , func (t * testing.T ) {
82
92
must .Must1 (db .Reset (ctx ))
0 commit comments