Refactor TestTransaction() so its decoupled from the adapters

This commit is contained in:
Vinícius Garcia 2022-02-19 10:56:47 -03:00
parent 90f63e5f14
commit cea28ace2b

View File

@ -2069,6 +2069,21 @@ func QueryChunksTest(
func TestTransaction(t *testing.T) { func TestTransaction(t *testing.T) {
for _, config := range supportedConfigs { for _, config := range supportedConfigs {
TransactionTest(t,
config,
func(t *testing.T) (DBAdapter, io.Closer) {
db, close := connectDB(t, config)
return db, close
},
)
}
}
func TransactionTest(
t *testing.T,
config testConfig,
newDBAdapter func(t *testing.T) (DBAdapter, io.Closer),
) {
t.Run(config.driver, func(t *testing.T) { t.Run(config.driver, func(t *testing.T) {
t.Run("should query a single row correctly", func(t *testing.T) { t.Run("should query a single row correctly", func(t *testing.T) {
err := createTables(config.driver) err := createTables(config.driver)
@ -2134,7 +2149,6 @@ func TestTransaction(t *testing.T) {
assert.Equal(t, []User{u1, u2}, users) assert.Equal(t, []User{u1, u2}, users)
}) })
}) })
}
} }
func TestScanRows(t *testing.T) { func TestScanRows(t *testing.T) {