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
|
||||
}
|
||||
|
||||
t.Run(config.adapterName+"."+config.driver, func(t *testing.T) {
|
||||
QueryTest(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)
|
||||
TransactionTest(t, config, newDBAdapter)
|
||||
ScanRowsTest(t, config, newDBAdapter)
|
||||
})
|
||||
}
|
||||
|
||||
func QueryTest(
|
||||
|
@ -110,7 +112,7 @@ func QueryTest(
|
|||
config testConfig,
|
||||
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 {
|
||||
desc string
|
||||
queryPrefix string
|
||||
|
@ -506,7 +508,7 @@ func QueryOneTest(
|
|||
config testConfig,
|
||||
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 {
|
||||
desc string
|
||||
queryPrefix string
|
||||
|
@ -685,7 +687,7 @@ func InsertTest(
|
|||
config testConfig,
|
||||
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("single primary key tables", func(t *testing.T) {
|
||||
err := createTables(config.driver)
|
||||
|
@ -1021,7 +1023,7 @@ func DeleteTest(
|
|||
config testConfig,
|
||||
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)
|
||||
if err != nil {
|
||||
t.Fatal("could not create test table!, reason:", err.Error())
|
||||
|
@ -1323,7 +1325,7 @@ func UpdateTest(
|
|||
config testConfig,
|
||||
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)
|
||||
if err != nil {
|
||||
t.Fatal("could not create test table!, reason:", err.Error())
|
||||
|
@ -1508,7 +1510,7 @@ func QueryChunksTest(
|
|||
config testConfig,
|
||||
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 {
|
||||
desc string
|
||||
queryPrefix string
|
||||
|
@ -2022,7 +2024,7 @@ func TransactionTest(
|
|||
config testConfig,
|
||||
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) {
|
||||
err := createTables(config.driver)
|
||||
if err != nil {
|
||||
|
@ -2094,6 +2096,7 @@ func ScanRowsTest(
|
|||
config testConfig,
|
||||
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) {
|
||||
err := createTables(config.driver)
|
||||
if err != nil {
|
||||
|
@ -2223,6 +2226,7 @@ func ScanRowsTest(
|
|||
err = scanRows(dialect, rows, &u)
|
||||
tt.AssertErrContains(t, err, "ksql", "expected", "pointer to struct", "map[string]interface")
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
func connectDB(t *testing.T, config testConfig) (DBAdapter, io.Closer) {
|
||||
|
|
Loading…
Reference in New Issue