Add migrations tests

This commit is contained in:
2024-11-24 00:17:08 +01:00
parent 9d81b1036d
commit 1e7cd0934e
4 changed files with 192 additions and 1 deletions

View File

@@ -0,0 +1,30 @@
//go:build test
package db
import (
"database/sql"
"novamd/internal/secrets"
)
type TestDatabase interface {
Database
TestDB() *sql.DB
}
func NewTestDB(dbPath string, secretsService secrets.Service) (TestDatabase, error) {
db, err := Init(dbPath, secretsService)
if err != nil {
return nil, err
}
return &testDatabase{db.(*database)}, nil
}
type testDatabase struct {
*database
}
func (td *testDatabase) TestDB() *sql.DB {
return td.DB
}