Fix pgpassfile for compat tests

This commit is contained in:
Patrick O'brien 2016-09-24 16:16:44 +10:00
parent e157a59714
commit 0dc68e749e

View file

@ -101,7 +101,7 @@ func (p *pgTester) pgEnv() []string {
fmt.Sprintf("PGHOST=%s", p.host), fmt.Sprintf("PGHOST=%s", p.host),
fmt.Sprintf("PGPORT=%d", p.port), fmt.Sprintf("PGPORT=%d", p.port),
fmt.Sprintf("PGUSER=%s", p.user), fmt.Sprintf("PGUSER=%s", p.user),
fmt.Sprintf("PGPASS=%s", p.pgPassFile), fmt.Sprintf("PGPASSFILE=%s", p.pgPassFile),
} }
} }
@ -111,6 +111,12 @@ func (p *pgTester) makePGPassFile() error {
return errors.Wrap(err, "failed to create option file") return errors.Wrap(err, "failed to create option file")
} }
fmt.Fprintf(tmp, "%s:%d:postgres:%s", p.host, p.port, p.user)
if len(p.pass) != 0 {
fmt.Fprintf(tmp, ":%s", p.pass)
}
fmt.Fprintln(tmp)
fmt.Fprintf(tmp, "%s:%d:%s:%s", p.host, p.port, p.dbName, p.user) fmt.Fprintf(tmp, "%s:%d:%s:%s", p.host, p.port, p.dbName, p.user)
if len(p.pass) != 0 { if len(p.pass) != 0 {
fmt.Fprintf(tmp, ":%s", p.pass) fmt.Fprintf(tmp, ":%s", p.pass)