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) {
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("should query a single row correctly", func(t *testing.T) {
err := createTables(config.driver)
@ -2135,7 +2150,6 @@ func TestTransaction(t *testing.T) {
})
})
}
}
func TestScanRows(t *testing.T) {
t.Run("should scan users correctly", func(t *testing.T) {