You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi... I'm facing an issue in my Go application when using go-sqlmock for unit testing my database interactions. The problem arises when trying to simulate a row scan error using sql.ErrNoRows. Although I've set up the test case for such a scenario, it seems that the specific line of code within my repository function is not covered by the test, and I'm not sure why. I would appreciate any help or insights on how to properly handle this case.
is not being covered by my tests, even though I have a test case (TestListRowScanError) specifically designed to simulate the error using sql.ErrNoRows. The other test cases (TestListSuccess and TestListFail) are working as expected, but I'm having trouble understanding why the row scan error is not being triggered.
Requested Help
I would greatly appreciate any guidance or suggestions on how to properly test and cover the specific scenario of a row scan error using go-sqlmock. If there's anything I'm missing in my test setup or if there's a better way to test this kind of situation, please let me know.
Thank you in advance for your help and insights!
The text was updated successfully, but these errors were encountered:
Issue Description
Hi... I'm facing an issue in my Go application when using
go-sqlmock
for unit testing my database interactions. The problem arises when trying to simulate a row scan error usingsql.ErrNoRows
. Although I've set up the test case for such a scenario, it seems that the specific line of code within my repository function is not covered by the test, and I'm not sure why. I would appreciate any help or insights on how to properly handle this case.Code Sample
I have a function in my repository like this:
And here are the relevant test cases:
Problem
The issue I'm encountering is that the specific code block where I check for errors during row scanning:
is not being covered by my tests, even though I have a test case (
TestListRowScanError
) specifically designed to simulate the error using sql.ErrNoRows. The other test cases (TestListSuccess
andTestListFail
) are working as expected, but I'm having trouble understanding why the row scan error is not being triggered.Requested Help
I would greatly appreciate any guidance or suggestions on how to properly test and cover the specific scenario of a row scan error using
go-sqlmock
. If there's anything I'm missing in my test setup or if there's a better way to test this kind of situation, please let me know.Thank you in advance for your help and insights!
The text was updated successfully, but these errors were encountered: