@@ -8,30 +8,31 @@ import (
8
8
"database/sql"
9
9
sqldriver "database/sql/driver"
10
10
"fmt"
11
- "log"
12
-
11
+ "github.com/dhui/dktest"
13
12
"github.com/golang-migrate/migrate/v4"
13
+ "github.com/golang-migrate/migrate/v4/database"
14
+ dt "github.com/golang-migrate/migrate/v4/database/testing"
15
+ "github.com/golang-migrate/migrate/v4/dktesting"
16
+ _ "github.com/golang-migrate/migrate/v4/source/file"
14
17
"io"
18
+ "log"
15
19
"strconv"
16
20
"strings"
17
21
"testing"
18
22
)
19
23
20
- import (
21
- "github.com/dhui/dktest"
22
- )
23
-
24
- import (
25
- "github.com/golang-migrate/migrate/v4/database"
26
- dt "github.com/golang-migrate/migrate/v4/database/testing"
27
- "github.com/golang-migrate/migrate/v4/dktesting"
28
- _ "github.com/golang-migrate/migrate/v4/source/file"
24
+ const (
25
+ pgPassword = "postgres"
29
26
)
30
27
31
28
var (
32
- opts = dktest.Options {PortRequired : true , ReadyFunc : isReady }
29
+ opts = dktest.Options {
30
+ Env : map [string ]string {"POSTGRES_PASSWORD" : pgPassword },
31
+ PortRequired : true ,
32
+ ReadyFunc : isReady ,
33
+ }
33
34
specs = []dktesting.ContainerSpec {
34
- {ImageName : "postgres:8 " , Options : opts },
35
+ {ImageName : "postgres:12 " , Options : opts },
35
36
}
36
37
)
37
38
@@ -44,7 +45,7 @@ func pgConnectionString(host, port string) string {
44
45
}
45
46
46
47
func connectionString (schema , host , port string ) string {
47
- return fmt .Sprintf ("%s://postgres@%s:%s/postgres?sslmode=disable" , schema , host , port )
48
+ return fmt .Sprintf ("%s://postgres:%s @%s:%s/postgres?sslmode=disable" , schema , pgPassword , host , port )
48
49
}
49
50
50
51
func isReady (ctx context.Context , c dktest.ContainerInfo ) bool {
@@ -192,7 +193,7 @@ func TestFilterCustomQuery(t *testing.T) {
192
193
t .Fatal (err )
193
194
}
194
195
195
- addr := fmt .Sprintf ("postgres://postgres@%v:%v /postgres?sslmode=disable&x-custom=foobar" , ip , port )
196
+ addr := fmt .Sprintf ("postgres://postgres:%s@%s:%s /postgres?sslmode=disable&x-custom=foobar" , pgPassword , ip , port )
196
197
p := & Redshift {}
197
198
d , err := p .Open (addr )
198
199
if err != nil {
@@ -234,7 +235,7 @@ func TestWithSchema(t *testing.T) {
234
235
}
235
236
236
237
// re-connect using that schema
237
- d2 , err := p .Open (fmt .Sprintf ("postgres://postgres@%v:%v /postgres?sslmode=disable&search_path=foobar" , ip , port ))
238
+ d2 , err := p .Open (fmt .Sprintf ("postgres://postgres:%s@%s:%s /postgres?sslmode=disable&search_path=foobar" , pgPassword , ip , port ))
238
239
if err != nil {
239
240
t .Fatal (err )
240
241
}
0 commit comments