Skip to content

Commit 595050f

Browse files
authored
Merge branch 'main' into peerdebug
2 parents f4c9dc2 + f9e594f commit 595050f

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

.github/workflows/coder.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ jobs:
159159
run:
160160
DB=true gotestsum --jsonfile="gotests.json" --packages="./..." --
161161
-covermode=atomic -coverprofile="gotests.coverage" -timeout=3m
162-
-count=1 -race -parallel=1
162+
-count=1 -race -parallel=2
163163

164164
- uses: codecov/codecov-action@v2
165165
with:

database/postgres/postgres.go

+17
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ package postgres
33
import (
44
"database/sql"
55
"fmt"
6+
"io/ioutil"
7+
"os"
68
"time"
79

810
"github.com/ory/dockertest/v3"
@@ -16,15 +18,29 @@ func Open() (string, func(), error) {
1618
if err != nil {
1719
return "", nil, xerrors.Errorf("create pool: %w", err)
1820
}
21+
tempDir, err := ioutil.TempDir(os.TempDir(), "postgres")
22+
if err != nil {
23+
return "", nil, xerrors.Errorf("create tempdir: %w", err)
24+
}
1925
resource, err := pool.RunWithOptions(&dockertest.RunOptions{
2026
Repository: "postgres",
2127
Tag: "11",
2228
Env: []string{
2329
"POSTGRES_PASSWORD=postgres",
2430
"POSTGRES_USER=postgres",
2531
"POSTGRES_DB=postgres",
32+
// The location for temporary database files!
33+
"PGDATA=/tmp",
2634
"listen_addresses = '*'",
2735
},
36+
Mounts: []string{
37+
// The postgres image has a VOLUME parameter in it's image.
38+
// If we don't mount at this point, Docker will allocate a
39+
// volume for this directory.
40+
//
41+
// This isn't used anyways, since we override PGDATA.
42+
fmt.Sprintf("%s:/var/lib/postgresql/data", tempDir),
43+
},
2844
}, func(config *docker.HostConfig) {
2945
// set AutoRemove to true so that stopped container goes away by itself
3046
config.AutoRemove = true
@@ -57,5 +73,6 @@ func Open() (string, func(), error) {
5773
}
5874
return dbURL, func() {
5975
_ = pool.Purge(resource)
76+
_ = os.RemoveAll(tempDir)
6077
}, nil
6178
}

0 commit comments

Comments
 (0)