mirror of https://github.com/VinGarcia/ksql.git
Refactor tests so the error descriptions are more clear
parent
ea4f56fadd
commit
a51e9730c3
|
@ -94,6 +94,7 @@ func RunTestsForAdapter(t *testing.T, config testConfig) {
|
||||||
return db, close
|
return db, close
|
||||||
}
|
}
|
||||||
|
|
||||||
|
t.Run(config.adapterName+"."+config.driver, func(t *testing.T) {
|
||||||
QueryTest(t, config, newDBAdapter)
|
QueryTest(t, config, newDBAdapter)
|
||||||
QueryOneTest(t, config, newDBAdapter)
|
QueryOneTest(t, config, newDBAdapter)
|
||||||
QueryOneTest(t, config, newDBAdapter)
|
QueryOneTest(t, config, newDBAdapter)
|
||||||
|
@ -103,6 +104,7 @@ func RunTestsForAdapter(t *testing.T, config testConfig) {
|
||||||
QueryChunksTest(t, config, newDBAdapter)
|
QueryChunksTest(t, config, newDBAdapter)
|
||||||
TransactionTest(t, config, newDBAdapter)
|
TransactionTest(t, config, newDBAdapter)
|
||||||
ScanRowsTest(t, config, newDBAdapter)
|
ScanRowsTest(t, config, newDBAdapter)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func QueryTest(
|
func QueryTest(
|
||||||
|
@ -110,7 +112,7 @@ func QueryTest(
|
||||||
config testConfig,
|
config testConfig,
|
||||||
newDBAdapter func(t *testing.T) (DBAdapter, io.Closer),
|
newDBAdapter func(t *testing.T) (DBAdapter, io.Closer),
|
||||||
) {
|
) {
|
||||||
t.Run(config.driver, func(t *testing.T) {
|
t.Run("QueryTest", func(t *testing.T) {
|
||||||
variations := []struct {
|
variations := []struct {
|
||||||
desc string
|
desc string
|
||||||
queryPrefix string
|
queryPrefix string
|
||||||
|
@ -506,7 +508,7 @@ func QueryOneTest(
|
||||||
config testConfig,
|
config testConfig,
|
||||||
newDBAdapter func(t *testing.T) (DBAdapter, io.Closer),
|
newDBAdapter func(t *testing.T) (DBAdapter, io.Closer),
|
||||||
) {
|
) {
|
||||||
t.Run(config.driver, func(t *testing.T) {
|
t.Run("QueryOne", func(t *testing.T) {
|
||||||
variations := []struct {
|
variations := []struct {
|
||||||
desc string
|
desc string
|
||||||
queryPrefix string
|
queryPrefix string
|
||||||
|
@ -685,7 +687,7 @@ func InsertTest(
|
||||||
config testConfig,
|
config testConfig,
|
||||||
newDBAdapter func(t *testing.T) (DBAdapter, io.Closer),
|
newDBAdapter func(t *testing.T) (DBAdapter, io.Closer),
|
||||||
) {
|
) {
|
||||||
t.Run(config.driver, func(t *testing.T) {
|
t.Run("Insert", func(t *testing.T) {
|
||||||
t.Run("success cases", func(t *testing.T) {
|
t.Run("success cases", func(t *testing.T) {
|
||||||
t.Run("single primary key tables", func(t *testing.T) {
|
t.Run("single primary key tables", func(t *testing.T) {
|
||||||
err := createTables(config.driver)
|
err := createTables(config.driver)
|
||||||
|
@ -1021,7 +1023,7 @@ func DeleteTest(
|
||||||
config testConfig,
|
config testConfig,
|
||||||
newDBAdapter func(t *testing.T) (DBAdapter, io.Closer),
|
newDBAdapter func(t *testing.T) (DBAdapter, io.Closer),
|
||||||
) {
|
) {
|
||||||
t.Run(config.driver, func(t *testing.T) {
|
t.Run("Delete", func(t *testing.T) {
|
||||||
err := createTables(config.driver)
|
err := createTables(config.driver)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal("could not create test table!, reason:", err.Error())
|
t.Fatal("could not create test table!, reason:", err.Error())
|
||||||
|
@ -1323,7 +1325,7 @@ func UpdateTest(
|
||||||
config testConfig,
|
config testConfig,
|
||||||
newDBAdapter func(t *testing.T) (DBAdapter, io.Closer),
|
newDBAdapter func(t *testing.T) (DBAdapter, io.Closer),
|
||||||
) {
|
) {
|
||||||
t.Run(config.driver, func(t *testing.T) {
|
t.Run("Update", func(t *testing.T) {
|
||||||
err := createTables(config.driver)
|
err := createTables(config.driver)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal("could not create test table!, reason:", err.Error())
|
t.Fatal("could not create test table!, reason:", err.Error())
|
||||||
|
@ -1508,7 +1510,7 @@ func QueryChunksTest(
|
||||||
config testConfig,
|
config testConfig,
|
||||||
newDBAdapter func(t *testing.T) (DBAdapter, io.Closer),
|
newDBAdapter func(t *testing.T) (DBAdapter, io.Closer),
|
||||||
) {
|
) {
|
||||||
t.Run(config.driver, func(t *testing.T) {
|
t.Run("QueryChunks", func(t *testing.T) {
|
||||||
variations := []struct {
|
variations := []struct {
|
||||||
desc string
|
desc string
|
||||||
queryPrefix string
|
queryPrefix string
|
||||||
|
@ -2022,7 +2024,7 @@ func TransactionTest(
|
||||||
config testConfig,
|
config testConfig,
|
||||||
newDBAdapter func(t *testing.T) (DBAdapter, io.Closer),
|
newDBAdapter func(t *testing.T) (DBAdapter, io.Closer),
|
||||||
) {
|
) {
|
||||||
t.Run(config.driver, func(t *testing.T) {
|
t.Run("Transaction", 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)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -2094,6 +2096,7 @@ func ScanRowsTest(
|
||||||
config testConfig,
|
config testConfig,
|
||||||
newDBAdapter func(t *testing.T) (DBAdapter, io.Closer),
|
newDBAdapter func(t *testing.T) (DBAdapter, io.Closer),
|
||||||
) {
|
) {
|
||||||
|
t.Run("ScanRows", func(t *testing.T) {
|
||||||
t.Run("should scan users correctly", func(t *testing.T) {
|
t.Run("should scan users correctly", func(t *testing.T) {
|
||||||
err := createTables(config.driver)
|
err := createTables(config.driver)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -2223,6 +2226,7 @@ func ScanRowsTest(
|
||||||
err = scanRows(dialect, rows, &u)
|
err = scanRows(dialect, rows, &u)
|
||||||
tt.AssertErrContains(t, err, "ksql", "expected", "pointer to struct", "map[string]interface")
|
tt.AssertErrContains(t, err, "ksql", "expected", "pointer to struct", "map[string]interface")
|
||||||
})
|
})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func connectDB(t *testing.T, config testConfig) (DBAdapter, io.Closer) {
|
func connectDB(t *testing.T, config testConfig) (DBAdapter, io.Closer) {
|
||||||
|
|
Loading…
Reference in New Issue