2021-06-03 14:35:34 +01:00
|
|
|
package state
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"testing"
|
2021-07-21 15:28:31 +01:00
|
|
|
|
2023-01-18 14:54:26 +00:00
|
|
|
"github.com/jmoiron/sqlx"
|
2022-12-15 11:08:50 +00:00
|
|
|
"github.com/matrix-org/sliding-sync/testutils"
|
2021-06-03 14:35:34 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
var postgresConnectionString = "user=xxxxx dbname=syncv3_test sslmode=disable"
|
|
|
|
|
2021-06-03 15:23:07 +01:00
|
|
|
func TestMain(m *testing.M) {
|
2021-11-09 10:15:48 +00:00
|
|
|
postgresConnectionString = testutils.PrepareDBConnectionString()
|
2021-06-03 14:35:34 +01:00
|
|
|
exitCode := m.Run()
|
|
|
|
os.Exit(exitCode)
|
|
|
|
}
|
2023-01-18 14:54:26 +00:00
|
|
|
|
|
|
|
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()
|
|
|
|
}
|
|
|
|
}
|