forked from doug-martin/goqu
-
Notifications
You must be signed in to change notification settings - Fork 2
/
goqu_test.go
61 lines (49 loc) · 1.47 KB
/
goqu_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
package goqu_test
import (
"testing"
"github.com/DATA-DOG/go-sqlmock"
"github.com/doug-martin/goqu/v9"
"github.com/stretchr/testify/suite"
)
type (
dialectWrapperSuite struct {
suite.Suite
}
)
func (dws *dialectWrapperSuite) SetupSuite() {
testDialect := goqu.DefaultDialectOptions()
// override to some value to ensure correct dialect is set
goqu.RegisterDialect("test", "db", testDialect)
}
func (dws *dialectWrapperSuite) TearDownSuite() {
goqu.DeregisterDialect("test")
}
func (dws *dialectWrapperSuite) TestFrom() {
dw := goqu.Dialect("test")
dws.Equal(goqu.From("table").WithDialect("test"), dw.From("table"))
}
func (dws *dialectWrapperSuite) TestSelect() {
dw := goqu.Dialect("test")
dws.Equal(goqu.Select("col").WithDialect("test"), dw.Select("col"))
}
func (dws *dialectWrapperSuite) TestInsert() {
dw := goqu.Dialect("test")
dws.Equal(goqu.Insert("table").WithDialect("test"), dw.Insert("table"))
}
func (dws *dialectWrapperSuite) TestDelete() {
dw := goqu.Dialect("test")
dws.Equal(goqu.Delete("table").WithDialect("test"), dw.Delete("table"))
}
func (dws *dialectWrapperSuite) TestTruncate() {
dw := goqu.Dialect("test")
dws.Equal(goqu.Truncate("table").WithDialect("test"), dw.Truncate("table"))
}
func (dws *dialectWrapperSuite) TestDB() {
mDB, _, err := sqlmock.New()
dws.Require().NoError(err)
dw := goqu.Dialect("test")
dws.Equal(goqu.New("test", mDB), dw.DB(mDB))
}
func TestDialectWrapper(t *testing.T) {
suite.Run(t, new(dialectWrapperSuite))
}