mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-16 18:43:10 -06:00
Don't fail tests if we're unable to connect to a postgres server
This commit is contained in:
parent
87d03616c2
commit
352d44823f
|
|
@ -65,6 +65,10 @@ func createRemoteDB(t *testing.T, dbName, user, connStr string) {
|
||||||
fatalError(t, "failed to open postgres conn with connstr=%s : %s", connStr, err)
|
fatalError(t, "failed to open postgres conn with connstr=%s : %s", connStr, err)
|
||||||
}
|
}
|
||||||
if err = db.Ping(); err != nil {
|
if err = db.Ping(); err != nil {
|
||||||
|
// If we're unable to reach the database, it's unlikely that a postgres server is
|
||||||
|
// available for testing. Set Required to false to skip the test instead of failing it.
|
||||||
|
Required = false
|
||||||
|
t.Logf("Note: tests require a postgres install accessible to the current user")
|
||||||
fatalError(t, "failed to open postgres conn with connstr=%s : %s", connStr, err)
|
fatalError(t, "failed to open postgres conn with connstr=%s : %s", connStr, err)
|
||||||
}
|
}
|
||||||
_, err = db.Exec(fmt.Sprintf(`CREATE DATABASE %s;`, dbName))
|
_, err = db.Exec(fmt.Sprintf(`CREATE DATABASE %s;`, dbName))
|
||||||
|
|
@ -169,9 +173,6 @@ func PrepareDBConnectionString(t *testing.T, dbType DBType) (connStr string, clo
|
||||||
|
|
||||||
// Creates subtests with each known DBType
|
// Creates subtests with each known DBType
|
||||||
func WithAllDatabases(t *testing.T, testFn func(t *testing.T, db DBType)) {
|
func WithAllDatabases(t *testing.T, testFn func(t *testing.T, db DBType)) {
|
||||||
if testing.Short() {
|
|
||||||
t.Skip("skipping test in short mode.")
|
|
||||||
}
|
|
||||||
dbs := map[string]DBType{
|
dbs := map[string]DBType{
|
||||||
"postgres": DBTypePostgres,
|
"postgres": DBTypePostgres,
|
||||||
"sqlite": DBTypeSQLite,
|
"sqlite": DBTypeSQLite,
|
||||||
|
|
|
||||||
|
|
@ -30,9 +30,6 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func CreateBaseDendrite(t *testing.T, dbType test.DBType) (*base.BaseDendrite, func()) {
|
func CreateBaseDendrite(t *testing.T, dbType test.DBType) (*base.BaseDendrite, func()) {
|
||||||
if testing.Short() {
|
|
||||||
t.Skip("skipping test in short mode.")
|
|
||||||
}
|
|
||||||
var cfg config.Dendrite
|
var cfg config.Dendrite
|
||||||
cfg.Defaults(config.DefaultOpts{
|
cfg.Defaults(config.DefaultOpts{
|
||||||
Generate: false,
|
Generate: false,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue