mirror of
https://github.com/matrix-org/sliding-sync.git
synced 2025-03-10 13:37:11 +00:00
28 lines
555 B
Go
28 lines
555 B
Go
package state
|
|
|
|
import (
|
|
"os"
|
|
"testing"
|
|
|
|
"github.com/jmoiron/sqlx"
|
|
"github.com/matrix-org/sliding-sync/testutils"
|
|
)
|
|
|
|
var postgresConnectionString = "user=xxxxx dbname=syncv3_test sslmode=disable"
|
|
|
|
func TestMain(m *testing.M) {
|
|
postgresConnectionString = testutils.PrepareDBConnectionString()
|
|
exitCode := m.Run()
|
|
os.Exit(exitCode)
|
|
}
|
|
|
|
func connectToDB(t *testing.T) (*sqlx.DB, func()) {
|
|
db, err := sqlx.Open("postgres", postgresConnectionString)
|
|
if err != nil {
|
|
t.Fatalf("failed to open SQL db: %s", err)
|
|
}
|
|
return db, func() {
|
|
db.Close()
|
|
}
|
|
}
|