forked from coder/coder
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpostgres_test.go
More file actions
39 lines (31 loc) · 720 Bytes
/
postgres_test.go
File metadata and controls
39 lines (31 loc) · 720 Bytes
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
//go:build linux
package postgres_test
import (
"database/sql"
"testing"
_ "github.com/lib/pq"
"github.com/stretchr/testify/require"
"go.uber.org/goleak"
"github.com/coder/coder/v2/coderd/database/postgres"
)
func TestMain(m *testing.M) {
goleak.VerifyTestMain(m)
}
// nolint:paralleltest
func TestPostgres(t *testing.T) {
// postgres.Open() seems to be creating race conditions when run in parallel.
// t.Parallel()
if testing.Short() {
t.SkipNow()
return
}
connect, closePg, err := postgres.Open()
require.NoError(t, err)
defer closePg()
db, err := sql.Open("postgres", connect)
require.NoError(t, err)
err = db.Ping()
require.NoError(t, err)
err = db.Close()
require.NoError(t, err)
}