Add error test case to QueryOne() for invalid SQL

pull/2/head
Vinícius Garcia 2021-02-26 22:43:32 -03:00
parent e7e89b63ef
commit e044d1fc30
1 changed files with 11 additions and 0 deletions

View File

@ -255,6 +255,17 @@ func TestQueryOne(t *testing.T) {
err = c.QueryOne(ctx, User{}, `SELECT * FROM users WHERE name like `+c.dialect.Placeholder(0), "% Sá")
assert.NotEqual(t, nil, err)
})
t.Run("should report error if the query is not valid", func(t *testing.T) {
db := connectDB(t, driver)
defer db.Close()
ctx := context.Background()
c := newTestDB(db, "postgres", "users")
var user User
err = c.QueryOne(ctx, &user, `SELECT * FROM not a valid query`)
assert.NotEqual(t, nil, err)
})
})
}
}