@@ -23,8 +23,14 @@ import (
23
23
_ "github.com/golang-migrate/migrate/v4/source/file"
24
24
)
25
25
26
+ const (
27
+ pgPassword = "postgres"
28
+ )
29
+
26
30
var (
27
- opts = dktest.Options {PortRequired : true , ReadyFunc : isReady }
31
+ opts = dktest.Options {
32
+ Env : map [string ]string {"POSTGRES_PASSWORD" : pgPassword },
33
+ PortRequired : true , ReadyFunc : isReady }
28
34
// Supported versions: https://www.postgresql.org/support/versioning/
29
35
specs = []dktesting.ContainerSpec {
30
36
{ImageName : "postgres:9.5" , Options : opts },
36
42
)
37
43
38
44
func pgConnectionString (host , port string ) string {
39
- return fmt .Sprintf ("postgres://postgres@%s:%s/postgres?sslmode=disable" , host , port )
45
+ return fmt .Sprintf ("postgres://postgres:%s @%s:%s/postgres?sslmode=disable" , pgPassword , host , port )
40
46
}
41
47
42
48
func isReady (ctx context.Context , c dktest.ContainerInfo ) bool {
@@ -184,7 +190,8 @@ func TestFilterCustomQuery(t *testing.T) {
184
190
t .Fatal (err )
185
191
}
186
192
187
- addr := fmt .Sprintf ("postgres://postgres@%v:%v/postgres?sslmode=disable&x-custom=foobar" , ip , port )
193
+ addr := fmt .Sprintf ("postgres://postgres:%s@%v:%v/postgres?sslmode=disable&x-custom=foobar" ,
194
+ pgPassword , ip , port )
188
195
p := & Postgres {}
189
196
d , err := p .Open (addr )
190
197
if err != nil {
@@ -226,7 +233,8 @@ func TestWithSchema(t *testing.T) {
226
233
}
227
234
228
235
// re-connect using that schema
229
- d2 , err := p .Open (fmt .Sprintf ("postgres://postgres@%v:%v/postgres?sslmode=disable&search_path=foobar" , ip , port ))
236
+ d2 , err := p .Open (fmt .Sprintf ("postgres://postgres:%s@%v:%v/postgres?sslmode=disable&search_path=foobar" ,
237
+ pgPassword , ip , port ))
230
238
if err != nil {
231
239
t .Fatal (err )
232
240
}
@@ -295,7 +303,8 @@ func TestParallelSchema(t *testing.T) {
295
303
}
296
304
297
305
// re-connect using that schemas
298
- dfoo , err := p .Open (fmt .Sprintf ("postgres://postgres@%v:%v/postgres?sslmode=disable&search_path=foo" , ip , port ))
306
+ dfoo , err := p .Open (fmt .Sprintf ("postgres://postgres:%s@%v:%v/postgres?sslmode=disable&search_path=foo" ,
307
+ pgPassword , ip , port ))
299
308
if err != nil {
300
309
t .Fatal (err )
301
310
}
@@ -305,7 +314,8 @@ func TestParallelSchema(t *testing.T) {
305
314
}
306
315
}()
307
316
308
- dbar , err := p .Open (fmt .Sprintf ("postgres://postgres@%v:%v/postgres?sslmode=disable&search_path=bar" , ip , port ))
317
+ dbar , err := p .Open (fmt .Sprintf ("postgres://postgres:%s@%v:%v/postgres?sslmode=disable&search_path=bar" ,
318
+ pgPassword , ip , port ))
309
319
if err != nil {
310
320
t .Fatal (err )
311
321
}
0 commit comments