Skip to content

Commit

Permalink
test: cleanup test databases to avoid side-effects
Browse files Browse the repository at this point in the history
  • Loading branch information
bevzzz committed Nov 3, 2023
1 parent 8a43835 commit dec1c73
Show file tree
Hide file tree
Showing 8 changed files with 156 additions and 203 deletions.
8 changes: 3 additions & 5 deletions internal/dbtest/bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func benchEachDB(b *testing.B, f func(b *testing.B, db *bun.DB)) {
db.SetMaxOpenConns(64)
db.SetMaxIdleConns(64)

err := resetBenchSchema(db)
err := resetBenchSchema(b, db)
require.NoError(b, err)

b.ResetTimer()
Expand All @@ -86,10 +86,8 @@ func benchEachDB(b *testing.B, f func(b *testing.B, db *bun.DB)) {
}
}

func resetBenchSchema(db *bun.DB) error {
if err := db.ResetModel(ctx, (*Bench)(nil)); err != nil {
return err
}
func resetBenchSchema(tb testing.TB, db *bun.DB) error {
mustResetModel(tb, ctx, db, (*Bench)(nil))

for i := 0; i < 1000; i++ {
bench := &Bench{
Expand Down
Loading

0 comments on commit dec1c73

Please sign in to comment.