Skip to content

Commit

Permalink
fix: debug
Browse files Browse the repository at this point in the history
  • Loading branch information
xlanor committed Dec 11, 2020
1 parent 16447f7 commit 5cc57b5
Showing 1 changed file with 0 additions and 30 deletions.
30 changes: 0 additions & 30 deletions sqlconx/dockertest/postgresql.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ func getRunOpts(containerExposedPort, containerName, pgUsername, pgPassword stri
"POSTGRES_PASSWORD=" + pgPassword,

},
ExposedPorts: []string{"5432"},
Name: containerName,
PortBindings: map[dc.Port][]dc.PortBinding{
"5432": {
Expand Down Expand Up @@ -105,32 +104,3 @@ func initalizePostgresDb(t* testing.T, opts dockertest.RunOptions) (*dockertest.
t.Log("Created database")
return resource, err
}

func bootstrap(t *testing.T, containerExposedPort, pgUsername, pgPassword string, resource *dockertest.Resource) (db *sqlx.DB) {
// uses sqlx to test for an alive connection,
if err := pool.Retry( func() error {
databaseConnStr := fmt.Sprintf("postgres://%s:%s@127.0.0.1:%s/postgres?sslmode=disable",
pgUsername,
pgPassword,
containerExposedPort,
)
var err error
t.Log(databaseConnStr)
db, err := sqlx.Connect("postgres", databaseConnStr)
if err != nil {
return err
}

return db.Ping()
}); err != nil {

if pErr := pool.Purge(resource); pErr != nil {
t.Logf("Could not connect to docker and unable to remove image: %s - %s\n", err, pErr)
require.NoError(t, pErr)
}
log.Fatalf("Could not connect to docker: %s", err)
require.NoError(t, err)
log.Info ("Removed image due to an error")
}
return
}

0 comments on commit 5cc57b5

Please sign in to comment.