-
Notifications
You must be signed in to change notification settings - Fork 23
test: replace sqlx test with testcontainers #787
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
test: replace sqlx test with testcontainers #787
Conversation
1e0a2e0
to
4a57d33
Compare
c3e0181
to
5d01552
Compare
Pull Request Test Coverage Report for Build 16432285415Details
💛 - Coveralls |
4a95373
to
d924db1
Compare
Signed-off-by: Joseph Livesey <[email protected]>
Signed-off-by: Joseph Livesey <[email protected]>
5466624
to
8f26845
Compare
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.
This is a great contribution to the testing infrastructure
I also loved the documentation, that is really helpful!
/// This creates an isolated PostgreSQL container and database for testing. | ||
/// The container will be kept alive as long as the returned TestDatabase | ||
/// instance is not dropped. | ||
pub async fn setup_shared_test_db() -> TestDatabase { |
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.
this is magic!
I will add something like this to graph-agent for sure!
Note on fix for test_retry_unaggregated_fees: Correcting RAV Mock Behavior
Problem Summary
The test
test_retry_unaggregated_fees
was failing with "Expected notify to be triggered" after recent testcontainers migration work. Investigation revealed the root cause was an incorrectly implemented mock behavior that didn't align with documented expectations.Root Cause Analysis
Original Mock Behavior (Incorrect)
The original
MockSenderAllocation
was sending successful RAV responses that did not clear unaggregated fees:This behavior was inconsistent with documented expectations. A comment in the codebase explicitly states:
Retry Logic Analysis
The sender account retry mechanism works as follows:
The deny condition is:
total_potential_fees = pending_ravs + unaggregated_fees > balance
Why the Test Was Passing Before
The test was artificially passing because:
unaggregated_fees
still exceeded the balance limitSolution Implemented
Added Comprehensive Documentation
Added detailed documentation throughout the code to explain:
Fixed Mock Behavior
Updated the mock to correctly implement the documented behavior:
Updated Test Expectations
Modified the test to expect the correct behavior:
Impact and Justification
Why This Fix Is Correct
Behavior Change
This change makes the test more accurate in representing real system behavior where successful RAV processing resolves the underlying deny condition and stops unnecessary retries.