blob: 1d65c60e6d75a7e3dbdcbdf3ea4a34241d192281 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
# Temp PostgreSQL
The `temp-postgres` utility runs the PostgreSQL server off a temporary data
directory. See [this][intro] blog post for an introduction.
This project's original source code is hosted [here][home].
[intro]: https://www.skreutz.com/posts/temporary-postgresql-server/
[home]: https://git.skreutz.com/temp-postgres.git/
## Usage
Create and serve a temporary database:
$ temp-postgres
Wrap the `psql` command to connect to the temporary database once the server is ready:
$ temp-postgres -- psql
Run [SQLx integration tests](https://docs.rs/sqlx/latest/sqlx/attr.test.html) against a temporary database:
$ temp-postgres -- cargo test
Or configure `temp-postgres` as a wrapper for [cargo-nextest](https://nexte.st/):
```toml
experimental = ["wrapper-scripts"]
[scripts.wrapper.temp-postgres]
command = 'temp-postgres'
[[profile.default.scripts]]
platform = { host = 'cfg(unix)' }
run-wrapper = 'temp-postgres'
```
See the manual page for details.
## Dependencies
The `temp-postgres` utility depends on `sh(1)` and `postgres(1)`.
On OpenBSD you can install the dependencies using `pkg_add(1)`:
$ doas pkg_add postgresql-server postgresql-client
On FreeBSD you can install the dependencies using `pkg-install(8)`:
$ sudo pkg install postgresql16-server postgresql16-client
On Void Linux you can install the dependencies using `xbps-install(1)`:
$ sudo xbps-install -S dash postgresql postgresql-client
On Arch Linux you can install the dependencies using `pacman(8)`:
$ sudo pacman -Syu postgresql
## Installation
$ ./configure
$ make
$ sudo make install
Alternatively you can run (or install) the experimental Nix flake.
$ nix run git+https://git.skreutz.com/temp-postgres.git -- --help
|
for my tech blog and contact information.