Add test to try to fix the test coverage issue

pull/53/head
Vinícius Garcia 2024-10-30 09:08:25 -03:00
parent 31dfbeca3f
commit be21a80750
3 changed files with 25 additions and 2 deletions

View File

@ -76,6 +76,9 @@ func startSQLServerDB(dbName string) (databaseURL string, closer func()) {
}
sqlDB.Close()
// SQLServer keeps failing frequently, lets try to wait a little before returning:
time.Sleep(500 * time.Millisecond)
return databaseUrl, func() {
if err := pool.Purge(resource); err != nil {
fmt.Printf("Could not purge resource: %s\n", err)

View File

@ -548,7 +548,7 @@ func (c DB) insertWithLastInsertID(
fallthrough
default:
return fmt.Errorf(
"can't convert last insert id of type int64 into field `%s` of type %v",
"error scanning field `%s` cannot assign last insert id of type int64 into field of type %v",
idName,
fieldType,
)

View File

@ -802,7 +802,6 @@ func InsertTest(
Age: 42,
}
ctx = InjectLogger(ctx, Logger)
err := c.Insert(ctx, NewTable("users", "name"), &u)
tt.AssertNoErr(t, err)
tt.AssertEqual(t, u.Name, "FernandaIsTheID")
@ -1073,6 +1072,27 @@ func InsertTest(
t.Fatal("could not create test table!, reason:", err.Error())
}
t.Run("should report error if the attribute used to retrieve the ID is not supported ", func(t *testing.T) {
c := newTestDB(db, dialect)
type invalidIDUser struct {
ID struct{} `ksql:"id"`
Name string `ksql:"name"`
Age int `ksql:"age"`
Address address `ksql:"address,json"`
}
u := invalidIDUser{
Name: "Mauro",
Address: address{
Country: "Brazil",
},
Age: 42,
}
err := c.Insert(ctx, usersTable, &u)
tt.AssertErrContains(t, err, "error", "scanning", "into", "struct {}")
})
t.Run("should report error for invalid input types", func(t *testing.T) {
c := newTestDB(db, dialect)