Support the 'redshift' URL scheme

This brings the 'redshift2' package in alignment with the existing
'redshift' package.
This commit is contained in:
Andrei Mackenzie 2018-11-03 18:44:11 -04:00
parent 3373343f23
commit 22334834ac
2 changed files with 14 additions and 5 deletions

View File

@ -94,6 +94,7 @@ func (p *Redshift) Open(url string) (database.Driver, error) {
if err != nil {
return nil, err
}
purl.Scheme = "postgres"
db, err := sql.Open("postgres", migrate.FilterCustomQuery(purl).String())
if err != nil {

View File

@ -25,8 +25,16 @@ var versions = []mt.Version{
{Image: "postgres:9.3"},
}
func redshiftConnectionString(host string, port uint) string {
return connectionString("redshift", host, port)
}
func pgConnectionString(host string, port uint) string {
return fmt.Sprintf("postgres://postgres@%s:%v/postgres?sslmode=disable", host, port)
return connectionString("postgres", host, port)
}
func connectionString(schema, host string, port uint) string {
return fmt.Sprintf("%s://postgres@%s:%v/postgres?sslmode=disable", schema, host, port)
}
func isReady(i mt.Instance) bool {
@ -52,7 +60,7 @@ func Test(t *testing.T) {
mt.ParallelTest(t, versions, isReady,
func(t *testing.T, i mt.Instance) {
p := &Redshift{}
addr := pgConnectionString(i.Host(), i.Port())
addr := redshiftConnectionString(i.Host(), i.Port())
d, err := p.Open(addr)
if err != nil {
t.Fatalf("%v", err)
@ -66,7 +74,7 @@ func TestMultiStatement(t *testing.T) {
mt.ParallelTest(t, versions, isReady,
func(t *testing.T, i mt.Instance) {
p := &Redshift{}
addr := pgConnectionString(i.Host(), i.Port())
addr := redshiftConnectionString(i.Host(), i.Port())
d, err := p.Open(addr)
if err != nil {
t.Fatalf("%v", err)
@ -91,7 +99,7 @@ func TestErrorParsing(t *testing.T) {
mt.ParallelTest(t, versions, isReady,
func(t *testing.T, i mt.Instance) {
p := &Redshift{}
addr := pgConnectionString(i.Host(), i.Port())
addr := redshiftConnectionString(i.Host(), i.Port())
d, err := p.Open(addr)
if err != nil {
t.Fatalf("%v", err)
@ -125,7 +133,7 @@ func TestWithSchema(t *testing.T) {
mt.ParallelTest(t, versions, isReady,
func(t *testing.T, i mt.Instance) {
p := &Redshift{}
addr := pgConnectionString(i.Host(), i.Port())
addr := redshiftConnectionString(i.Host(), i.Port())
d, err := p.Open(addr)
if err != nil {
t.Fatalf("%v", err)