You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Improve coverage for version_strategy.go
* Some style tweaks according to golangci-lint
* Cover alpine in a slightly different way
* Clear up debug logging
* Rename alpine check
* Add CircleCI build badge and format markdown.
Thank you for taking the time to contribute. These are mostly guidelines, not rules. Use your best judgment, and feel free to propose changes to this document in a pull request.
3
+
Thank you for taking the time to contribute. These are mostly guidelines, not rules. Use your best judgment, and feel
4
+
free to propose changes to this document in a pull request.
4
5
5
6
# Working with forked go repos
6
7
7
-
If you haven't worked with forked go repos before, take a look at this blog post for some excellent advice about [contributing to go open source git repositories](https://splice.com/blog/contributing-open-source-git-repositories-go/).
8
+
If you haven't worked with forked go repos before, take a look at this blog post for some excellent advice
9
+
about [contributing to go open source git repositories](https://splice.com/blog/contributing-open-source-git-repositories-go/)
10
+
.
8
11
9
12
# PRs
10
13
@@ -15,4 +18,5 @@ If you haven't worked with forked go repos before, take a look at this blog post
15
18
16
19
# Documentation
17
20
18
-
For simple typo fixes and documentation improvements feel free to raise a PR without raising an issue in github. For anything more complicated please file an issue.
21
+
For simple typo fixes and documentation improvements feel free to raise a PR without raising an issue in github. For
Run a real Postgres database locally on Linux, OSX or Windows as part of another Go application or test.
15
16
16
-
When testing this provides a higher level of confidence than using any in memory alternative. It also requires no other external dependencies outside of the Go build ecosystem.
17
+
When testing this provides a higher level of confidence than using any in memory alternative. It also requires no other
18
+
external dependencies outside of the Go build ecosystem.
17
19
18
-
Heavily inspired by Java projects [zonkyio/embedded-postgres](https://github.com/zonkyio/embedded-postgres) and [opentable/otj-pg-embedded](https://github.com/opentable/otj-pg-embedded) and reliant on the great work being done by [zonkyio/embedded-postgres-binaries](https://github.com/zonkyio/embedded-postgres-binaries) in order to fetch precompiled binaries from [Maven](https://mvnrepository.com/artifact/io.zonky.test.postgres/embedded-postgres-binaries-bom).
20
+
Heavily inspired by Java projects [zonkyio/embedded-postgres](https://github.com/zonkyio/embedded-postgres)
21
+
and [opentable/otj-pg-embedded](https://github.com/opentable/otj-pg-embedded) and reliant on the great work being done
22
+
by [zonkyio/embedded-postgres-binaries](https://github.com/zonkyio/embedded-postgres-binaries) in order to fetch
23
+
precompiled binaries
24
+
from [Maven](https://mvnrepository.com/artifact/io.zonky.test.postgres/embedded-postgres-binaries-bom).
19
25
20
26
## Installation
21
27
22
-
embedded-postgres uses Go modules and as such can be referenced by release version for use as a library. Use the following to add the latest release to your project.
28
+
embedded-postgres uses Go modules and as such can be referenced by release version for use as a library. Use the
29
+
following to add the latest release to your project.
23
30
24
31
```bash
25
32
go get -u github.com/fergusstrange/embedded-postgres
@@ -40,15 +47,15 @@ This library aims to require as little configuration as possible, favouring over
40
47
| Port | 5432 |
41
48
| StartTimeout | 15 Seconds |
42
49
43
-
The *RuntimePath* directory is erased and recreated at each `Start()` and therefore not
44
-
suitable for persistent data.
50
+
The *RuntimePath* directory is erased and recreated at each `Start()` and therefore not suitable for persistent data.
45
51
46
52
If a persistent data location is required, set *DataPath* to a directory outside *RuntimePath*.
47
53
48
-
If the *RuntimePath* directory is empty or already initialized but with an incompatible postgres version,
49
-
it will be removed and Postgres reinitialized.
54
+
If the *RuntimePath* directory is empty or already initialized but with an incompatible postgres version, it will be
55
+
removed and Postgres reinitialized.
50
56
51
57
A single Postgres instance can be created, started and stopped as follows
58
+
52
59
```go
53
60
postgres:= embeddedpostgres.NewDatabase()
54
61
err:= postgres.Start()
@@ -57,35 +64,40 @@ err := postgres.Start()
57
64
58
65
err:= postgres.Stop()
59
66
```
67
+
60
68
or with created with custom configuration
69
+
61
70
```go
62
71
logger:= &bytes.Byffer{}
63
72
postgres:=NewDatabase(DefaultConfig().
64
-
Username("beer").
65
-
Password("wine").
66
-
Database("gin").
67
-
Version(V12).
68
-
RuntimePath("/tmp").
69
-
Port(9876).
70
-
StartTimeout(45 * time.Second).
71
-
Logger(logger))
73
+
Username("beer").
74
+
Password("wine").
75
+
Database("gin").
76
+
Version(V12).
77
+
RuntimePath("/tmp").
78
+
Port(9876).
79
+
StartTimeout(45 * time.Second).
80
+
Logger(logger))
72
81
err:= postgres.Start()
73
82
74
83
// Do test logic
75
84
76
85
err:= postgres.Stop()
77
86
```
78
87
79
-
It should be noted that if `postgres.Stop()` is not called then the child Postgres process will not be released and the caller will block.
88
+
It should be noted that if `postgres.Stop()` is not called then the child Postgres process will not be released and the
89
+
caller will block.
80
90
81
91
## Examples
82
92
83
-
There are a number of realistic representations of how to use this library in [examples](https://github.com/fergusstrange/embedded-postgres/tree/master/examples).
93
+
There are a number of realistic representations of how to use this library
94
+
in [examples](https://github.com/fergusstrange/embedded-postgres/tree/master/examples).
84
95
85
96
## Credits
86
97
87
98
-[Gopherize Me](https://gopherize.me) Thanks for the awesome logo template.
88
-
-[zonkyio/embedded-postgres-binaries](https://github.com/zonkyio/embedded-postgres-binaries) Without which the precompiled Postgres binaries would not exist for this to work.
99
+
-[zonkyio/embedded-postgres-binaries](https://github.com/zonkyio/embedded-postgres-binaries) Without which the
100
+
precompiled Postgres binaries would not exist for this to work.
0 commit comments