-
-
Notifications
You must be signed in to change notification settings - Fork 402
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 support for repeatable assertions. #148
Conversation
Codecov Report
@@ Coverage Diff @@
## master #148 +/- ##
==========================================
- Coverage 91.02% 85.56% -5.47%
==========================================
Files 13 13
Lines 691 769 +78
==========================================
+ Hits 629 658 +29
- Misses 43 85 +42
- Partials 19 26 +7
Continue to review full report at Codecov.
|
This only matters for repeatable expectations but it's a no-op on non-repeatables.
Hi @coderanger , I'll have a look later, need to review it carefully |
👍 I can also write a bunch more tests to get the diff coverage up :) |
I was thinking about it lately and I'm afraid this may lead to some very tricky issues, like:
Could you explain the part of code which you needed this behavior for? because I think that was not a proper unit test. I understand that there is plenty of boilerplate in sqlmock, but it is consistent and yields expected behavior, I do not want to introduce something too complex, which may cause the unsolvable issues like mentioned above and I would rather force users to repeat those expectations if it tests larger piece of code. Otherwise it is better to use functional integration tests. |
The specific case is testing a Kubernetes operator. Basically it's a function running in the background on a tight loop, so the number of times the loop runs is based on exactly how fast the tests run in that particular moment. Unfortunately the SQL syntax I'm using isn't compatible with SQLite, so running a more functional-y test would require actually downloading and spinning up Postgres for each test :-/ |
well maybe you can extract that single call in this loop into a separate function in order to test it as unit. also you can make that call a functional interface, so you could mock it and test the whole behavior, for example calling it a third time it returns some failure result or something worth testing as an use case. What you describe, does not look like an appropriate use case worth adding this kind of feature. |
I do that too (testing single calls) and indeed those test cases don't require it, but tests for the reconciliation process as a whole need the loop running normally to simulate normal processing. I could also build my own Postgres interface but it would mean basically duplicating this project :) |
Love this added feature! I'm gonna use it! |
Implements #82.
The syntax looks like:
My specific use case is testing some polling APIs that might run any number of times during the test based on exact timing, but this seemed like a generally useful thing to have :-)