-
Notifications
You must be signed in to change notification settings - Fork 317
test: improve test coverage for pkg/datasource/sql/hook #978
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
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #978 +/- ##
==========================================
+ Coverage 45.90% 46.08% +0.18%
==========================================
Files 190 192 +2
Lines 11788 11832 +44
==========================================
+ Hits 5411 5453 +42
- Misses 5941 5943 +2
Partials 436 436 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Pull Request Overview
This PR adds comprehensive test coverage for SQL hook functionality in the datasource package, specifically for undo log and logger hooks.
- Adds 555 lines of tests for
undo_log_hook.gocovering various transaction scenarios - Adds 188 lines of tests for
logger_hook.gocovering logging behavior - Tests include mock implementations, edge cases, integration tests, and error scenarios
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| pkg/datasource/sql/hook/undo_log_hook_test.go | Comprehensive test suite for undo log hook functionality, including mock builders, global/non-global transactions, error handling, and integration tests |
| pkg/datasource/sql/hook/logger_hook_test.go | Complete test coverage for logger hook with various SQL query types, transaction contexts, and integration scenarios |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Parser might fail or succeed, both are acceptable in this test setup | ||
| assert.True(t, err == nil || err != nil) |
Copilot
AI
Nov 5, 2025
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 assertion is always true and provides no value. Remove this assertion or replace it with a meaningful check based on the expected behavior.
| // Parser might fail or succeed, both are acceptable in this test setup | |
| assert.True(t, err == nil || err != nil) | |
| // Ensure the mock builder's BeforeImage method was called | |
| assert.True(t, mockBuilder.beforeImageCalled, "BeforeImage should be called on the mock builder") |
| // Should handle nil TxCtx gracefully | ||
| err := hook.Before(ctx, execCtx) | ||
| // Might error due to nil TxCtx access or succeed | ||
| assert.True(t, err == nil || err != nil) |
Copilot
AI
Nov 5, 2025
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 assertion is always true and provides no value. Remove this assertion or replace it with a meaningful check.
| assert.True(t, err == nil || err != nil) |
| errAfter := hook.After(ctx, execCtx) | ||
|
|
||
| // Before may error on parse, After should never error | ||
| assert.True(t, errBefore == nil || errBefore != nil) |
Copilot
AI
Nov 5, 2025
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 assertion is always true and provides no value. Remove this assertion or replace it with a meaningful check.
| assert.True(t, errBefore == nil || errBefore != nil) |
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
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
Which issue(s) this PR fixes:
Fixes #937