forked from gobuffalo/pop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconnection_test.go
54 lines (42 loc) · 842 Bytes
/
connection_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
// +build sqlite
package pop
import (
"testing"
"github.com/stretchr/testify/require"
)
func Test_Connection_SimpleFlow(t *testing.T) {
r := require.New(t)
cd := &ConnectionDetails{
URL: "sqlite:///foo.db",
}
c, err := NewConnection(cd)
r.NoError(err)
err = c.Open()
r.NoError(err)
err = c.Open() // open again
r.NoError(err)
err = c.Close()
r.NoError(err)
}
func Test_Connection_Open_NoDialect(t *testing.T) {
r := require.New(t)
cd := &ConnectionDetails{
URL: "sqlite:///foo.db",
}
c, err := NewConnection(cd)
r.NoError(err)
c.Dialect = nil
err = c.Open()
r.Error(err)
}
func Test_Connection_Open_BadDialect(t *testing.T) {
r := require.New(t)
cd := &ConnectionDetails{
URL: "sqlite:///foo.db",
}
c, err := NewConnection(cd)
r.NoError(err)
cd.Dialect = "unknown"
err = c.Open()
r.Error(err)
}