aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorTill <2353100+S7evinK@users.noreply.github.com>2022-05-18 15:17:23 +0200
committerGitHub <noreply@github.com>2022-05-18 15:17:23 +0200
commitf321a7d55ea75e6a5276cd88eddcbbc82ceeaaeb (patch)
treec7243b9609cef4f92d79526318aaabebffff34d2 /test
parentb3162755a9053bbb30a83f00928ff0a0852ad32e (diff)
Really SKIP_NODB (#2472)
* Really SKIP_NODB * Use fatalError in createLocalDB * Check if createdb exists * Revert change * Remove !Quiet
Diffstat (limited to 'test')
-rw-r--r--test/db.go8
1 files changed, 6 insertions, 2 deletions
diff --git a/test/db.go b/test/db.go
index a1754cd0..c7cb919f 100644
--- a/test/db.go
+++ b/test/db.go
@@ -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)