-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add tests for query timeout #36
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! One thing that came to my mind was testing context cancellation, but we can't really test that it's being honored here? It's needs to be implemented and tested on the driver.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Great to have some integration tests.
Before this PR i really couldn't think of a good way to write tests for a
sql.DB
orQueryContext
without importing a package likesqlmock
. I've had a lot of trouble with sqlmock in the past.
mmh, sqlmock
worked quite well for me in the past (even though I have never used anything super complex). I actually added it here at #30. Something I should be aware of?
Yeah exactly. It's safe enough to assume that if you're using |
Before this PR i really couldn't think of a good way to write tests for a
sql.DB
orQueryContext
without importing a package likesqlmock
. I've had a lot of trouble with sqlmock in the past.I figured accepting an interface instead of a *sql.DB makes this testing process a lot easier. Let me know if there's anything else I should test while I'm in here.
Arguably this test itself isn't super valuable but at the very least it ensures that if the context in
db.QueryRowContext
is canceled, the cancellation causes an error to be returned by thequery
function.