-
Notifications
You must be signed in to change notification settings - Fork 0
/
huautla_test.go
74 lines (69 loc) · 1.59 KB
/
huautla_test.go
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
70
71
72
73
74
package huautla
import (
"fmt"
"testing"
"github.com/jsmit257/huautla/types"
"github.com/stretchr/testify/require"
)
func Test_New(t *testing.T) {
// in order to work, this test needs to run somewhere with an accessible database,
// and credentials in cleartext in this file; in our humble opinion, this test is
// too basic to warrant a whole test db instance
t.Skip()
t.Parallel()
tcs := map[string]struct {
cfg types.Config
err error
}{
// unfortunately, no happy path for this
"missing_hostname": {
cfg: types.Config{
PGUser: "postgres",
PGPass: "root",
PGPort: 5432,
},
err: fmt.Errorf("postgres connection needs hostname attribute"),
},
"missing_username": {
cfg: types.Config{
PGHost: "huautla",
PGPass: "root",
PGPort: 5432,
},
err: fmt.Errorf("postgres connection needs username attribute"),
},
"missing_password": {
cfg: types.Config{
PGHost: "huautla",
PGUser: "postgres",
PGPort: 5432,
},
err: fmt.Errorf("postgres connection needs password attribute"),
},
"missing_port": {
cfg: types.Config{
PGHost: "huautla",
PGUser: "postgres",
PGPass: "root",
},
err: fmt.Errorf("postgres connection needs port attribute"),
},
"missing_ssl": {
cfg: types.Config{
PGHost: "huautla",
PGUser: "postgres",
PGPass: "root",
PGPort: 5432,
},
err: fmt.Errorf("dial tcp: lookup huautla: no such host"),
},
}
for n, v := range tcs {
n, v := n, v
t.Run(n, func(t *testing.T) {
t.Parallel()
_, err := New(&v.cfg, nil)
require.Equal(t, v.err, err, err.Error())
})
}
}