Skip to content

Commit 0ff8479

Browse files
smolaRoberto Santalla
authored and
Roberto Santalla
committed
test: use DBHOST while running tests (#272)
This allows us to run tests against a PostgreSQL instance on a different host or a non-default port. Signed-off-by: Santiago M. Mola <[email protected]>
1 parent d770e29 commit 0ff8479

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

Diff for: benchmarks/bench_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@ func envOrDefault(key string, def string) string {
2222

2323
func dbURL() string {
2424
return fmt.Sprintf(
25-
"postgres://%s:%s@0.0.0.0:5432/%s?sslmode=disable",
25+
"postgres://%s:%s@%s/%s?sslmode=disable",
2626
envOrDefault("DBUSER", "testing"),
2727
envOrDefault("DBPASS", "testing"),
28+
envOrDefault("DBHOST", "0.0.0.0:5432"),
2829
envOrDefault("DBNAME", "testing"),
2930
)
3031
}

Diff for: common_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ func envOrDefault(key string, def string) string {
1919

2020
func openTestDB() (*sql.DB, error) {
2121
return sql.Open("postgres", fmt.Sprintf(
22-
"postgres://%s:%s@0.0.0.0:5432/%s?sslmode=disable",
22+
"postgres://%s:%s@%s/%s?sslmode=disable",
2323
envOrDefault("DBUSER", "testing"),
2424
envOrDefault("DBPASS", "testing"),
25+
envOrDefault("DBHOST", "0.0.0.0:5432"),
2526
envOrDefault("DBNAME", "testing"),
2627
))
2728
}

Diff for: types/slices_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -217,9 +217,10 @@ func envOrDefault(key string, def string) string {
217217

218218
func openTestDB() (*sql.DB, error) {
219219
return sql.Open("postgres", fmt.Sprintf(
220-
"postgres://%s:%s@0.0.0.0:5432/%s?sslmode=disable",
220+
"postgres://%s:%s@%s/%s?sslmode=disable",
221221
envOrDefault("DBUSER", "testing"),
222222
envOrDefault("DBPASS", "testing"),
223+
envOrDefault("DBHOST", "0.0.0.0:5432"),
223224
envOrDefault("DBNAME", "testing"),
224225
))
225226
}

0 commit comments

Comments
 (0)