Skip to content

Commit

Permalink
Fix redshift tests
Browse files Browse the repository at this point in the history
Newer versions of postgres require a password
  • Loading branch information
dhui authored and ramya-bangera committed Oct 17, 2024
1 parent 0891ef0 commit e1e3a42
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions database/redshift/redshift_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,17 @@ import (
_ "github.com/golang-migrate/migrate/v4/source/file"
)

const (
pgPassword = "redshift"
)

var (
opts = dktest.Options{PortRequired: true, ReadyFunc: isReady}
opts = dktest.Options{
Env: map[string]string{"POSTGRES_PASSWORD": pgPassword},
PortRequired: true,
ReadyFunc: isReady,
}

specs = []dktesting.ContainerSpec{
{ImageName: "postgres:8", Options: opts},
}
Expand All @@ -44,7 +53,7 @@ func pgConnectionString(host, port string) string {
}

func connectionString(schema, host, port string) string {
return fmt.Sprintf("%s://postgres@%s:%s/postgres?sslmode=disable", schema, host, port)
return fmt.Sprintf("%s://postgres:%s@%s:%s/postgres?sslmode=disable", schema, pgPassword, host, port)
}

func isReady(ctx context.Context, c dktest.ContainerInfo) bool {
Expand Down Expand Up @@ -192,7 +201,7 @@ func TestFilterCustomQuery(t *testing.T) {
t.Fatal(err)
}

addr := fmt.Sprintf("postgres://postgres@%v:%v/postgres?sslmode=disable&x-custom=foobar", ip, port)
addr := fmt.Sprintf("postgres://postgres:%s@%v:%v/postgres?sslmode=disable&x-custom=foobar", pgPassword, ip, port)
p := &Redshift{}
d, err := p.Open(addr)
if err != nil {
Expand Down Expand Up @@ -234,7 +243,7 @@ func TestWithSchema(t *testing.T) {
}

// re-connect using that schema
d2, err := p.Open(fmt.Sprintf("postgres://postgres@%v:%v/postgres?sslmode=disable&search_path=foobar", ip, port))
d2, err := p.Open(fmt.Sprintf("postgres://postgres:%s@%v:%v/postgres?sslmode=disable&search_path=foobar", pgPassword, ip, port))
if err != nil {
t.Fatal(err)
}
Expand Down

0 comments on commit e1e3a42

Please sign in to comment.