Really SKIP_NODB (#2472)

* Really SKIP_NODB

* Use fatalError in createLocalDB

* Check if createdb exists

* Revert change

* Remove !Quiet
This commit is contained in:
Till 2022-05-18 15:17:23 +02:00 committed by GitHub
parent b3162755a9
commit f321a7d55e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -44,8 +44,9 @@ func fatalError(t *testing.T, format string, args ...interface{}) {
}
func createLocalDB(t *testing.T, dbName string) {
if !Quiet {
t.Log("Note: tests require a postgres install accessible to the current user")
if _, err := exec.LookPath("createdb"); err != nil {
fatalError(t, "Note: tests require a postgres install accessible to the current user")
return
}
createDB := exec.Command("createdb", dbName)
if !Quiet {
@ -63,6 +64,9 @@ func createRemoteDB(t *testing.T, dbName, user, connStr string) {
if err != nil {
fatalError(t, "failed to open postgres conn with connstr=%s : %s", connStr, err)
}
if err = db.Ping(); err != nil {
fatalError(t, "failed to open postgres conn with connstr=%s : %s", connStr, err)
}
_, err = db.Exec(fmt.Sprintf(`CREATE DATABASE %s;`, dbName))
if err != nil {
pqErr, ok := err.(*pq.Error)