{"id":27756812,"url":"https://github.com/stevenacoffman/pgxtest","last_synced_at":"2025-04-29T08:43:58.512Z","repository":{"id":289183772,"uuid":"970379010","full_name":"StevenACoffman/pgxtest","owner":"StevenACoffman","description":"A Go test harness that starts an ephemeral PostgreSQL server with pgx","archived":false,"fork":false,"pushed_at":"2025-04-22T00:37:57.000Z","size":20,"stargazers_count":0,"open_issues_count":3,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-22T01:27:41.776Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","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/StevenACoffman.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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,"zenodo":null}},"created_at":"2025-04-21T23:36:07.000Z","updated_at":"2025-04-22T00:37:35.000Z","dependencies_parsed_at":"2025-04-22T01:37:50.344Z","dependency_job_id":null,"html_url":"https://github.com/StevenACoffman/pgxtest","commit_stats":null,"previous_names":["stevenacoffman/pgxtest"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StevenACoffman%2Fpgxtest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StevenACoffman%2Fpgxtest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StevenACoffman%2Fpgxtest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StevenACoffman%2Fpgxtest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/StevenACoffman","download_url":"https://codeload.github.com/StevenACoffman/pgxtest/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251469087,"owners_count":21594518,"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","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":[],"created_at":"2025-04-29T08:43:57.952Z","updated_at":"2025-04-29T08:43:58.500Z","avatar_url":"https://github.com/StevenACoffman.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `github.com/StevenACoffman/pgxtest`\n\n[![Reference](https://pkg.go.dev/badge/github.com/StevenACoffman/pgxtest?tab=doc)](https://pkg.go.dev/github.com/StevenACoffman/pgxtest?tab=doc)\n[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-v2.0%20adopted-ff69b4.svg)](CODE_OF_CONDUCT.md)\n\n### NOTE: This is a fork of https://github.com/zombiezen/postgrestest to use https://github.com/jackc/pgx\n\nThe readme below has not been updated to reflect recent code changes. PRs welcome!\n\nTODO(steve): I would further like to make the changes in https://github.com/gokrazy/gus/commit/b97c652fd03754ba817bd3c13f18ea6e2e154ef4#diff-7829468e86c1cc5d5133195b5cb48e1ff6c75e3e9203777f6b2e379d9e4882b3\nfrom https://michael.stapelberg.ch/posts/2024-11-19-testing-with-go-and-postgresql-ephemeral-dbs/\n\nPackage `pgxtest` provides a test harness that starts an ephemeral\n[PostgreSQL][] server. It is tested on macOS, Linux, and Windows. It can cut\ndown the overhead of PostgreSQL in tests up to 90% compared to spinning up a\n`postgres` Docker container: starting a server with this package takes\nroughly 650 milliseconds and creating a database takes roughly 20 milliseconds.\n\n[PostgreSQL]: https://www.postgresql.org/\n\n## Example\n\n```go\nfunc TestApp(t *testing.T) {\n\t// Start up the PostgreSQL server. This can take a few seconds, so better to\n\t// do it once per test run.\n\tctx := context.Background()\n\tsrv, err := postgrestest.Start(ctx)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tt.Cleanup(srv.Cleanup)\n\n\t// Each of your subtests can have their own database:\n\tt.Run(\"Test1\", func(t *testing.T) {\n\t\tdb, err := srv.NewDatabase(ctx)\n\t\tif err != nil {\n\t\t\tt.Fatal(err)\n\t\t}\n\t\tif _, err := db.Exec(`CREATE TABLE foo (id SERIAL PRIMARY KEY);`); err != nil {\n\t\t\tt.Fatal(err)\n\t\t}\n\t\t// ...\n\t})\n\n\tt.Run(\"Test2\", func(t *testing.T) {\n\t\tdb, err := srv.NewDatabase(ctx)\n\t\tif err != nil {\n\t\t\tt.Fatal(err)\n\t\t}\n\t\tif _, err := db.Exec(`CREATE TABLE foo (id SERIAL PRIMARY KEY);`); err != nil {\n\t\t\tt.Fatal(err)\n\t\t}\n\t\t// ...\n\t})\n}\n```\n\n## Installation\n\nPostgreSQL must be installed locally for this package to work. See the\n[PostgreSQL Downloads page][] for instructions on how to obtain PostgreSQL for\nyour operating system.\n\nTo install the package:\n\n```\ngo get github.com/StevenACoffman/pgxtest\n```\n\n[PostgreSQL Downloads page]: https://www.postgresql.org/download/\n\n## License\n\n[Apache 2.0](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstevenacoffman%2Fpgxtest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstevenacoffman%2Fpgxtest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstevenacoffman%2Fpgxtest/lists"}