test(coderd/database/dbtestutil): add debug output to pg_dump failure (#20209)

This commit is contained in:
Mathias Fredriksson
2025-10-08 14:22:35 +03:00
committed by GitHub
parent 544f15523c
commit 46e242e444
+3 -2
View File
@@ -242,10 +242,11 @@ func PGDump(dbURL string) ([]byte, error) {
"PGCLIENTENCODING=UTF8",
"PGDATABASE=", // we should always specify the database name in the connection string
}
var stdout bytes.Buffer
var stdout, stderr bytes.Buffer
cmd.Stdout = &stdout
cmd.Stderr = &stderr
if err := cmd.Run(); err != nil {
return nil, xerrors.Errorf("exec pg_dump: %w", err)
return nil, xerrors.Errorf("exec pg_dump: %w\n%s", err, stderr.String())
}
return stdout.Bytes(), nil
}