@@ -64,16 +64,16 @@ func newDatabase(ctx context.Context, typ string, cfg config.Database) (Database
6464 }
6565}
6666
67- // TestSuite -
68- type TestSuite struct {
67+ // DBTestSuite -
68+ type DBTestSuite struct {
6969 suite.Suite
7070 psqlContainer * PostgreSQLContainer
7171 db Database
7272 typ string
7373}
7474
7575// SetupSuite -
76- func (s * TestSuite ) SetupSuite () {
76+ func (s * DBTestSuite ) SetupSuite () {
7777 ctx , ctxCancel := context .WithTimeout (context .Background (), 30 * time .Second )
7878 defer ctxCancel ()
7979
@@ -98,15 +98,15 @@ func (s *TestSuite) SetupSuite() {
9898 s .Require ().NoError (err )
9999}
100100
101- func (s * TestSuite ) TearDownSuite () {
101+ func (s * DBTestSuite ) TearDownSuite () {
102102 ctx , ctxCancel := context .WithTimeout (context .Background (), 5 * time .Second )
103103 defer ctxCancel ()
104104
105105 s .Require ().NoError (s .db .Close ())
106106 s .Require ().NoError (s .psqlContainer .Terminate (ctx ))
107107}
108108
109- func (s * TestSuite ) TestStateCreate () {
109+ func (s * DBTestSuite ) TestStateCreate () {
110110 db , err := sql .Open ("postgres" , s .psqlContainer .GetDSN ())
111111 s .Require ().NoError (err )
112112
@@ -137,7 +137,7 @@ func (s *TestSuite) TestStateCreate() {
137137 s .Require ().Equal (state .UpdatedAt , newState .UpdatedAt )
138138}
139139
140- func (s * TestSuite ) TestStateUpdate () {
140+ func (s * DBTestSuite ) TestStateUpdate () {
141141 db , err := sql .Open ("postgres" , s .psqlContainer .GetDSN ())
142142 s .Require ().NoError (err )
143143
@@ -167,7 +167,7 @@ func (s *TestSuite) TestStateUpdate() {
167167 s .Require ().Equal (state .UpdatedAt , newState .UpdatedAt )
168168}
169169
170- func (s * TestSuite ) TestState () {
170+ func (s * DBTestSuite ) TestState () {
171171 db , err := sql .Open ("postgres" , s .psqlContainer .GetDSN ())
172172 s .Require ().NoError (err )
173173
@@ -191,7 +191,7 @@ func (s *TestSuite) TestState() {
191191 s .Require ().Equal (state .IndexName , testIndex )
192192}
193193
194- func (s * TestSuite ) TestDeleteState () {
194+ func (s * DBTestSuite ) TestDeleteState () {
195195 db , err := sql .Open ("postgres" , s .psqlContainer .GetDSN ())
196196 s .Require ().NoError (err )
197197
@@ -215,22 +215,43 @@ func (s *TestSuite) TestDeleteState() {
215215 s .Require ().Error (err )
216216}
217217
218- func (s * TestSuite ) TestPing () {
218+ func (s * DBTestSuite ) TestPing () {
219219 ctx , ctxCancel := context .WithTimeout (context .Background (), 5 * time .Second )
220220 defer ctxCancel ()
221221
222222 s .Require ().NoError (s .db .Ping (ctx ))
223223}
224224
225- func (s * TestSuite ) TestMakeComments () {
225+ func (s * DBTestSuite ) TestMakeComments () {
226226 ctx , ctxCancel := context .WithTimeout (context .Background (), 5 * time .Second )
227227 defer ctxCancel ()
228228
229229 s .Require ().NoError (MakeComments (ctx , s .db , & State {}))
230230}
231231
232+ func (s * DBTestSuite ) TestExec () {
233+ db , err := sql .Open ("postgres" , s .psqlContainer .GetDSN ())
234+ s .Require ().NoError (err )
235+
236+ fixtures , err := testfixtures .New (
237+ testfixtures .Database (db ),
238+ testfixtures .Dialect ("postgres" ),
239+ testfixtures .Directory ("fixtures" ),
240+ )
241+ s .Require ().NoError (err )
242+ s .Require ().NoError (fixtures .Load ())
243+ s .Require ().NoError (db .Close ())
244+
245+ ctx , ctxCancel := context .WithTimeout (context .Background (), 5 * time .Second )
246+ defer ctxCancel ()
247+
248+ count , err := s .db .Exec (ctx , "delete from dipdup_state where index_name = ?" , testIndex )
249+ s .Require ().NoError (err )
250+ s .Require ().EqualValues (1 , count )
251+ }
252+
232253func TestSuite_Run (t * testing.T ) {
233- ts := new (TestSuite )
254+ ts := new (DBTestSuite )
234255 for _ , typ := range []string {"gorm" , "pg-go" , "bun" } {
235256 ts .typ = typ
236257 }
0 commit comments