-
Notifications
You must be signed in to change notification settings - Fork 208
/
sql_dialect_internal_test.go
91 lines (70 loc) · 2.27 KB
/
sql_dialect_internal_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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package goqu
import (
"testing"
"github.com/doug-martin/goqu/v9/exp"
"github.com/doug-martin/goqu/v9/internal/sb"
"github.com/doug-martin/goqu/v9/sqlgen/mocks"
"github.com/stretchr/testify/suite"
)
type dialectTestSuite struct {
suite.Suite
}
func (dts *dialectTestSuite) TestDialect() {
opts := DefaultDialectOptions()
sm := new(mocks.SelectSQLGenerator)
d := sqlDialect{dialect: "test", dialectOptions: opts, selectGen: sm}
dts.Equal("test", d.Dialect())
}
func (dts *dialectTestSuite) TestToSelectSQL() {
opts := DefaultDialectOptions()
sm := new(mocks.SelectSQLGenerator)
d := sqlDialect{dialect: "test", dialectOptions: opts, selectGen: sm}
b := sb.NewSQLBuilder(true)
sc := exp.NewSelectClauses()
sm.On("Generate", b, sc).Return(nil).Once()
d.ToSelectSQL(b, sc)
sm.AssertExpectations(dts.T())
}
func (dts *dialectTestSuite) TestToUpdateSQL() {
opts := DefaultDialectOptions()
um := new(mocks.UpdateSQLGenerator)
d := sqlDialect{dialect: "test", dialectOptions: opts, updateGen: um}
b := sb.NewSQLBuilder(true)
uc := exp.NewUpdateClauses()
um.On("Generate", b, uc).Return(nil).Once()
d.ToUpdateSQL(b, uc)
um.AssertExpectations(dts.T())
}
func (dts *dialectTestSuite) TestToInsertSQL() {
opts := DefaultDialectOptions()
im := new(mocks.InsertSQLGenerator)
d := sqlDialect{dialect: "test", dialectOptions: opts, insertGen: im}
b := sb.NewSQLBuilder(true)
ic := exp.NewInsertClauses()
im.On("Generate", b, ic).Return(nil).Once()
d.ToInsertSQL(b, ic)
im.AssertExpectations(dts.T())
}
func (dts *dialectTestSuite) TestToDeleteSQL() {
opts := DefaultDialectOptions()
dm := new(mocks.DeleteSQLGenerator)
d := sqlDialect{dialect: "test", dialectOptions: opts, deleteGen: dm}
b := sb.NewSQLBuilder(true)
dc := exp.NewDeleteClauses()
dm.On("Generate", b, dc).Return(nil).Once()
d.ToDeleteSQL(b, dc)
dm.AssertExpectations(dts.T())
}
func (dts *dialectTestSuite) TestToTruncateSQL() {
opts := DefaultDialectOptions()
tm := new(mocks.TruncateSQLGenerator)
d := sqlDialect{dialect: "test", dialectOptions: opts, truncateGen: tm}
b := sb.NewSQLBuilder(true)
tc := exp.NewTruncateClauses()
tm.On("Generate", b, tc).Return(nil).Once()
d.ToTruncateSQL(b, tc)
tm.AssertExpectations(dts.T())
}
func TestSQLDialect(t *testing.T) {
suite.Run(t, new(dialectTestSuite))
}