{"id":17770389,"url":"https://github.com/allenap/rust-postgresfixture","last_synced_at":"2025-10-12T01:36:28.677Z","repository":{"id":37983753,"uuid":"95324415","full_name":"allenap/rust-postgresfixture","owner":"allenap","description":"A fixture for creating PostgreSQL clusters and databases, and tearing them down again, intended for use during development and testing.","archived":false,"fork":false,"pushed_at":"2023-11-28T04:44:26.000Z","size":222,"stargazers_count":3,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-12T01:36:25.777Z","etag":null,"topics":["rust-lang","rust-library","testing","testing-tools"],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/allenap.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-06-24T21:44:50.000Z","updated_at":"2024-04-24T07:35:51.000Z","dependencies_parsed_at":"2024-10-26T21:53:18.755Z","dependency_job_id":"88fe90e7-c9fd-4d7d-b863-371d8bc28102","html_url":"https://github.com/allenap/rust-postgresfixture","commit_stats":{"total_commits":137,"total_committers":4,"mean_commits":34.25,"dds":"0.24087591240875916","last_synced_commit":"752ffcbe11cf30ea071da5582399ca1bfe332d58"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/allenap/rust-postgresfixture","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allenap%2Frust-postgresfixture","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allenap%2Frust-postgresfixture/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allenap%2Frust-postgresfixture/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allenap%2Frust-postgresfixture/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/allenap","download_url":"https://codeload.github.com/allenap/rust-postgresfixture/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allenap%2Frust-postgresfixture/sbom","scorecard":{"id":185294,"data":{"date":"2025-08-11","repo":{"name":"github.com/allenap/rust-postgresfixture","commit":"16d7ea7a8cc49129ace72839c791c06fe2feaeba"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.1,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/13 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/build.yml:1","Warn: no topLevel permission defined: .github/workflows/release.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build.yml:13: update your workflow using https://app.stepsecurity.io/secureworkflow/allenap/rust-postgresfixture/build.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/build.yml:14: update your workflow using https://app.stepsecurity.io/secureworkflow/allenap/rust-postgresfixture/build.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build.yml:39: update your workflow using https://app.stepsecurity.io/secureworkflow/allenap/rust-postgresfixture/build.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/build.yml:40: update your workflow using https://app.stepsecurity.io/secureworkflow/allenap/rust-postgresfixture/build.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build.yml:47: update your workflow using https://app.stepsecurity.io/secureworkflow/allenap/rust-postgresfixture/build.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/build.yml:48: update your workflow using https://app.stepsecurity.io/secureworkflow/allenap/rust-postgresfixture/build.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build.yml:57: update your workflow using https://app.stepsecurity.io/secureworkflow/allenap/rust-postgresfixture/build.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/build.yml:58: update your workflow using https://app.stepsecurity.io/secureworkflow/allenap/rust-postgresfixture/build.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:89: update your workflow using https://app.stepsecurity.io/secureworkflow/allenap/rust-postgresfixture/release.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:93: update your workflow using https://app.stepsecurity.io/secureworkflow/allenap/rust-postgresfixture/release.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/release.yml:100: update your workflow using https://app.stepsecurity.io/secureworkflow/allenap/rust-postgresfixture/release.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:13: update your workflow using https://app.stepsecurity.io/secureworkflow/allenap/rust-postgresfixture/release.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/release.yml:14: update your workflow using https://app.stepsecurity.io/secureworkflow/allenap/rust-postgresfixture/release.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/release.yml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/allenap/rust-postgresfixture/release.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:19: update your workflow using https://app.stepsecurity.io/secureworkflow/allenap/rust-postgresfixture/release.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:29: update your workflow using https://app.stepsecurity.io/secureworkflow/allenap/rust-postgresfixture/release.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/release.yml:30: update your workflow using https://app.stepsecurity.io/secureworkflow/allenap/rust-postgresfixture/release.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/release.yml:33: update your workflow using https://app.stepsecurity.io/secureworkflow/allenap/rust-postgresfixture/release.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:35: update your workflow using https://app.stepsecurity.io/secureworkflow/allenap/rust-postgresfixture/release.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:46: update your workflow using https://app.stepsecurity.io/secureworkflow/allenap/rust-postgresfixture/release.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:50: update your workflow using https://app.stepsecurity.io/secureworkflow/allenap/rust-postgresfixture/release.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:62: update your workflow using https://app.stepsecurity.io/secureworkflow/allenap/rust-postgresfixture/release.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:72: update your workflow using https://app.stepsecurity.io/secureworkflow/allenap/rust-postgresfixture/release.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/release.yml:73: update your workflow using https://app.stepsecurity.io/secureworkflow/allenap/rust-postgresfixture/release.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/release.yml:76: update your workflow using https://app.stepsecurity.io/secureworkflow/allenap/rust-postgresfixture/release.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:78: update your workflow using https://app.stepsecurity.io/secureworkflow/allenap/rust-postgresfixture/release.yml/master?enable=pin","Info:   0 out of  15 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of  11 third-party GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: Apache License 2.0: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":0,"reason":"Project has not signed or included provenance with any releases.","details":["Warn: release artifact v0.5.0 not signed: https://api.github.com/repos/allenap/rust-postgresfixture/releases/124189316","Warn: release artifact v0.4.0 not signed: https://api.github.com/repos/allenap/rust-postgresfixture/releases/124181569","Warn: release artifact v0.3.3 not signed: https://api.github.com/repos/allenap/rust-postgresfixture/releases/93705435","Warn: release artifact v0.3.2 not signed: https://api.github.com/repos/allenap/rust-postgresfixture/releases/64403409","Warn: release artifact v0.5.0 does not have provenance: https://api.github.com/repos/allenap/rust-postgresfixture/releases/124189316","Warn: release artifact v0.4.0 does not have provenance: https://api.github.com/repos/allenap/rust-postgresfixture/releases/124181569","Warn: release artifact v0.3.3 does not have provenance: https://api.github.com/repos/allenap/rust-postgresfixture/releases/93705435","Warn: release artifact v0.3.2 does not have provenance: https://api.github.com/repos/allenap/rust-postgresfixture/releases/64403409"],"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 23 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-16T19:42:20.725Z","repository_id":37983753,"created_at":"2025-08-16T19:42:20.725Z","updated_at":"2025-08-16T19:42:20.725Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279009743,"owners_count":26084648,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-11T02:00:06.511Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["rust-lang","rust-library","testing","testing-tools"],"created_at":"2024-10-26T21:22:46.349Z","updated_at":"2025-10-12T01:36:28.662Z","avatar_url":"https://github.com/allenap.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"**⚠️ Development has moved to [pgdo](https://github.com/allenap/pgdo).**\n\n---\n\n# rust-postgresfixture\n\nA [Rust](https://www.rust-lang.org/) library and command-line tool for creating\nstandalone PostgreSQL clusters and databases, useful for experimentation,\ndevelopment, and testing.\n\nIt's based on the Python [postgresfixture][] library which saw heavy use in\n[MAAS](https://maas.io/). That was (and is) a useful tool when experimenting\nwith PostgreSQL. For example we could use it to bring up a cluster to run a\ndevelopment server. However, it came into its own in MAAS's test suites, and was\nkey to [making MAAS's test suites faster][maas-faster-tests].\n\n[postgresfixture]: https://pypi.python.org/pypi/postgresfixture\n[maas-faster-tests]: https://allenap.me/post/the-way-to-run-tests-quickly-in-maas\n\nThis Rust version started out as a straightforward port but it has deviated\nsignificantly from the design of its Python counterpart.\n\nThis code works and seems to be reliable, but the command-line and API may\nchange before 1.0, potentially causing breakage. If this is a problem I suggest\npinning on a specific version and checking back once in a while to see if it can\nbe upgraded, or use something automated like [Dependabot][dependabot].\n\n[dependabot]: https://github.com/dependabot\n\n## Command-line utility\n\nAfter [installing Cargo][install-cargo], `cargo install postgresfixture` will\ninstall a `postgresfixture` binary in `~/.cargo/bin`, which the Cargo\ninstallation process will probably have added to your `PATH`.\n\n**Note** that this tool does _not_ come with any PostgreSQL runtimes. You must\ninstall these yourself and add their `bin` directories to `PATH`. To select a\nspecific runtime you must set `PATH` such that the runtime you want to use is\nbefore any others. The `runtimes` subcommand can show you what is available and\nwhat runtime will actually be used.\n\n```shellsession\n$ postgresfixture --help\nEasily create and manage PostgreSQL clusters on demand for testing and development.\n\nUsage: postgresfixture \u003cCOMMAND\u003e\n\nCommands:\n  shell     Start a psql shell, creating and starting the cluster as necessary\n  exec      Execute an arbitrary command, creating and starting the cluster as necessary\n  runtimes  List discovered PostgreSQL runtimes\n  help      Print this message or the help of the given subcommand(s)\n\nOptions:\n  -h, --help     Print help\n  -V, --version  Print version\n\n$ postgresfixture runtimes\n   10.22      /opt/homebrew/Cellar/postgresql@10/10.22_6/bin\n   11.21      /opt/homebrew/Cellar/postgresql@11/11.21/bin\n   12.16      /opt/homebrew/Cellar/postgresql@12/12.16/bin\n   13.12      /opt/homebrew/Cellar/postgresql@13/13.12/bin\n   14.9       /opt/homebrew/Cellar/postgresql@14/14.9/bin\n   15.4       /opt/homebrew/Cellar/postgresql@15/15.4/bin\n=\u003e 16.0       /opt/homebrew/bin\n\n$ postgresfixture shell\npostgres=# select …\n\n$ postgresfixture exec pg_dump\n--\n-- PostgreSQL database dump\n--\n…\n```\n\n## Use as a library\n\nThe essential functionality in this crate is in the `Cluster` struct and its\nimplementation. This covers the logic you need to create, run, and destroy\nPostgreSQL clusters of any officially supported version (and a few older\nversions that are not supported upstream).\n\n```rust\nuse postgresfixture::prelude::*;\nfor runtime in runtime::strategy::default().runtimes() {\n  let data_dir = tempdir::TempDir::new(\"data\")?;\n  let cluster = Cluster::new(\u0026data_dir, runtime)?;\n  cluster.start()?;\n  assert_eq!(cluster.databases()?, vec![\"postgres\", \"template0\", \"template1\"]);\n  let mut conn = cluster.connect(\"template1\")?;\n  let rows = conn.query(\"SELECT 1234 -- …\", \u0026[])?;\n  let collations: Vec\u003ci32\u003e = rows.iter().map(|row| row.get(0)).collect();\n  assert_eq!(collations, vec![1234]);\n  cluster.stop()?;\n}\n# Ok::\u003c(), ClusterError\u003e(())\n```\n\nYou may want to use this with the functions in the `coordinate` module like\n`run_and_stop` and `run_and_destroy`. These add locking to the setup and\nteardown steps of using a cluster so that multiple processes can safely share a\nsingle on-demand cluster.\n\n## Contributing\n\nIf you feel the urge to hack on this code, here's\nhow to get started:\n\n- [Install cargo][install-cargo],\n- Clone this repository,\n- Build it: `cargo build`.\n\n[install-cargo]: https://crates.io/install\n\n### Running the tests\n\nAfter installing the source (see above) run tests with: `cargo test`.\n\n**However**, it's important to test against multiple versions of PostgreSQL. The\ntests will look for all PostgreSQL runtimes on `PATH` and run tests for all of\nthem.\n\nFirst you must install multiple versions of PostgreSQL on your machine. Read on\nfor platform-specific notes. Once you've installed the versions you want,\n[`postgresfixture::runtime::strategy::default()`] may be able to automatically\nfind them – and, since this function is used by tests, those runtimes will\nautomatically be tested.\n\n#### Debian \u0026 Ubuntu\n\nFrom https://wiki.postgresql.org/wiki/Apt:\n\n```shellsession\n$ sudo apt-get install -y postgresql-common\n$ sudo sh /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh -y\n$ sudo apt-get install -y postgresql-{9.{4,5,6},10,11,12,13}  # Adjust as necessary.\n```\n\n#### macOS\n\nUsing [Homebrew](https://brew.sh/):\n\n```shellsession\n$ brew install postgresql  # Latest version.\n$ brew install postgresql@{9.{4,5,6},10,11,12,13}  # Adjust as necessary.\n```\n\n### Making a release\n\n1. Bump version in [`Cargo.toml`](Cargo.toml).\n2. Paste updated `--help` output into [`README.md`](README.md) (this file; see\n   near the top). On macOS the command `cargo run -- --help | pbcopy` is\n   helpful.\n3. Build **and** test: `cargo build \u0026\u0026 cargo test`. The latter on its own does\n   do a build, but a test build can hide warnings about dead code, so do both.\n4. Commit with message \"Bump version to `$VERSION`.\"\n5. Tag with \"v`$VERSION`\", e.g. `git tag v1.0.10`.\n6. Push: `git push \u0026\u0026 git push --tags`.\n7. Publish: `cargo publish`.\n\n## License\n\nThis project is licensed under the Apache 2.0 License. See the\n[LICENSE](LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fallenap%2Frust-postgresfixture","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fallenap%2Frust-postgresfixture","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fallenap%2Frust-postgresfixture/lists"}