Set max open conns to 1 for test code to fix race conditions that lead to flaky tests

This commit is contained in:
David Dworken 2023-02-13 20:50:33 -08:00
parent 413e2e438f
commit 8dc5168c64
No known key found for this signature in database

View File

@ -493,6 +493,11 @@ func OpenDB() (*gorm.DB, error) {
if err != nil {
return nil, fmt.Errorf("failed to connect to the DB: %v", err)
}
underlyingDb, err := db.DB()
if err != nil {
return nil, fmt.Errorf("failed to access underlying DB: %v", err)
}
underlyingDb.SetMaxOpenConns(1)
db.Exec("PRAGMA journal_mode = WAL")
AddDatabaseTables(db)
return db, nil