-
Notifications
You must be signed in to change notification settings - Fork 39
Test pruner and refactor newDB #788
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
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. |
WalkthroughThe changes remove explicit cleanup function returns and calls from test database setup utilities and all dependent test files, instead relying on Go's Changes
Sequence Diagram(s)sequenceDiagram
participant TestFunction
participant testutils.NewDB
participant t.Cleanup
TestFunction->>testutils.NewDB: Create test DB
testutils.NewDB->>t.Cleanup: Register DB cleanup callback
TestFunction-->>testutils.NewDB: Receives DB handle only
Note right of TestFunction: No explicit cleanup function returned or deferred
sequenceDiagram
participant Test as Prune Test
participant setupTestData
participant makeTestExecutor
participant prune.Executor
participant DB
Test->>setupTestData: Insert expired & valid envelopes
Test->>makeTestExecutor: Create prune executor
Test->>prune.Executor: Run()
prune.Executor->>DB: Delete expired envelopes
Test->>DB: Query remaining envelopes
Test->>Test: Assert expected state
Suggested reviewers
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 golangci-lint (1.64.8)Error: you are using a configuration file for golangci-lint v2 with golangci-lint v1: please use golangci-lint v2 Tip ⚡️ Faster reviews with caching
Enjoy the performance boost—your workflow just got faster. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (18)
🧰 Additional context used🧬 Code Graph Analysis (17)pkg/fees/calculator_test.go (1)
pkg/db/sequences_test.go (1)
pkg/payerreport/manager_test.go (1)
pkg/db/unsettledUsage_test.go (1)
pkg/indexer/storer/identityUpdate_test.go (1)
pkg/db/gatewayEnvelope_test.go (1)
pkg/indexer/storer/groupMessage_test.go (1)
pkg/blockchain/nonceManager_test.go (1)
pkg/indexer/e2e_test.go (1)
pkg/server/server_test.go (1)
pkg/db/subscription_test.go (1)
pkg/db/congestion_test.go (2)
pkg/testutils/api/api.go (1)
pkg/indexer/blockTracker_test.go (1)
pkg/db/queries_test.go (1)
pkg/registrant/registrant_test.go (4)
pkg/prune/prune_test.go (6)
⏰ Context from checks skipped due to timeout of 90000ms (5)
🔇 Additional comments (43)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
| config *config.PruneConfig, | ||
| ) *prune.Executor { | ||
| return prune.NewPruneExecutor( | ||
| ctx, |
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.
I've recently discovered t.Context(), which is a context that gets canceled at the end of the test. And it stops you from needing to pass around the context separate from testing.T.
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.
oooh! Love it!
Refactor database cleanup handling in tests to use testing framework's t.Cleanup() mechanism instead of explicit cleanup functions
t.Cleanup()mechanism in store.goNewDBandNewDBsfunctions in store.go to no longer return cleanup functions📍Where to Start
Start with the core changes to database cleanup handling in store.go, particularly the
openDBfunction which now registers cleanup witht.Cleanup()instead of returning a cleanup function.Macroscope summarized d1a4b2a.
Summary by CodeRabbit