Skip to content

Commit

Permalink
testutils: fix pg dump path
Browse files Browse the repository at this point in the history
  • Loading branch information
alexisvisco committed May 19, 2024
1 parent b77ab3c commit fa92bcd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,7 @@ jobs:
done
- name: Run tests
env:
PG_DUMP_PATH: /usr/bin/pg_dump
run: |
go test -v ./...
15 changes: 13 additions & 2 deletions pkg/utils/testutils/snapshoting.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func MaySnapshotSavePgDump(t TestingT, schemaName string, db schema.DatabaseCred

env := map[string]string{"PGPASSWORD": db.Pass}

_, _, err = cmdexec.Exec("/opt/homebrew/opt/libpq/bin/pg_dump", args, env)
_, _, err = cmdexec.Exec(getPgDumpPath(), args, env)
require.NoError(t, err)

return
Expand Down Expand Up @@ -168,7 +168,7 @@ func AssertSnapshotPgDumpDiff(t TestingT, schemaName string, db schema.DatabaseC

env := map[string]string{"PGPASSWORD": db.Pass}

_, _, err := cmdexec.Exec("/opt/homebrew/opt/libpq/bin/pg_dump", args, env)
_, _, err := cmdexec.Exec(getPgDumpPath(), args, env)
require.NoError(t, err)

snap, err := os.ReadFile(fileSnap)
Expand All @@ -191,3 +191,14 @@ func AssertSnapshotPgDumpDiff(t TestingT, schemaName string, db schema.DatabaseC
t.Errorf("snapshots are different between %s and %s:\n%s", fileSnap, fileOut, out)
}
}

func getPgDumpPath() string {
def := "/opt/homebrew/opt/libpq/bin/pg_dump"

// If the PG_DUMP_PATH is set, use it
if os.Getenv("PG_DUMP_PATH") != "" {
def = os.Getenv("PG_DUMP_PATH")
}

return def
}

0 comments on commit fa92bcd

Please sign in to comment.