Skip to content

Conversation

@everfid-ever
Copy link
Contributor

Which issue(s) this PR fixes:

Fixes #937

@slievrly slievrly requested a review from Copilot November 5, 2025 03:07
@slievrly slievrly added this to the 2.1.0 milestone Nov 5, 2025
@codecov-commenter
Copy link

codecov-commenter commented Nov 5, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 46.08%. Comparing base (df6a5a9) to head (e969e2e).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

Copilot AI left a 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.go covering various transaction scenarios
  • Adds 188 lines of tests for logger_hook.go covering 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.

Comment on lines +167 to +168
// Parser might fail or succeed, both are acceptable in this test setup
assert.True(t, err == nil || err != nil)
Copy link

Copilot AI Nov 5, 2025

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.

Suggested change
// 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")

Copilot uses AI. Check for mistakes.
// 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)
Copy link

Copilot AI Nov 5, 2025

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.

Suggested change
assert.True(t, err == nil || err != nil)

Copilot uses AI. Check for mistakes.
errAfter := hook.After(ctx, execCtx)

// Before may error on parse, After should never error
assert.True(t, errBefore == nil || errBefore != nil)
Copy link

Copilot AI Nov 5, 2025

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.

Suggested change
assert.True(t, errBefore == nil || errBefore != nil)

Copilot uses AI. Check for mistakes.
Copy link
Member

@slievrly slievrly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@slievrly slievrly merged commit ad92ad8 into apache:master Nov 5, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve test coverage for pkg/datasource/sql/hook

3 participants