Skip to content

Conversation

@Suhaibinator
Copy link
Owner

No description provided.

@Suhaibinator Suhaibinator requested a review from Copilot June 8, 2025 20:53

This comment was marked as outdated.

@codecov
Copy link

codecov bot commented Jun 8, 2025

Codecov Report

Attention: Patch coverage is 93.79310% with 9 lines in your changes missing coverage. Please review.

Project coverage is 96.95%. Comparing base (1cbdacb) to head (c1e9974).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
pkg/router/route.go 71.42% 4 Missing and 2 partials ⚠️
pkg/router/router.go 96.25% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #87      +/-   ##
==========================================
- Coverage   97.16%   96.95%   -0.22%     
==========================================
  Files          18       19       +1     
  Lines        2363     2492     +129     
==========================================
+ Hits         2296     2416     +120     
- Misses         55       61       +6     
- Partials       12       15       +3     

☔ 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.

@Suhaibinator Suhaibinator requested a review from Copilot June 8, 2025 21:10

This comment was marked as outdated.

@Suhaibinator Suhaibinator requested a review from Copilot June 8, 2025 21:29

This comment was marked as outdated.

@Suhaibinator Suhaibinator requested a review from Copilot June 8, 2025 21:55

This comment was marked as outdated.

- Added validation logic to ensure that if any transaction is enabled (global, sub-router, or route level), a TransactionFactory must be provided.
- Introduced panic scenarios for invalid configurations to prevent router startup with missing TransactionFactory.
- Created comprehensive tests to cover various transaction validation scenarios, including global, sub-router, and route-level configurations.
- Ensured that dynamically registered sub-routers bypass validation checks, maintaining expected behavior.
- Updated existing tests to reflect changes in handler registration to use http.HandlerFunc consistently.
- Removed unused responseWriter type and related tests to streamline codebase.
@Suhaibinator Suhaibinator requested a review from Copilot June 9, 2025 00:29
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 support for automatic transaction management across the router by introducing a TransactionFactory, extending configs, updating examples/tests, and providing mock implementations.

  • Introduce TransactionFactory interface and TransactionConfig overrides in common and router configurations
  • Add mock transaction types and extend tests/examples to cover transaction flows
  • Update existing route registration calls to include the new transaction override parameter

Reviewed Changes

Copilot reviewed 33 out of 33 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
pkg/router/internal/mocks/transaction_mocks.go Add mock implementations (MockTransaction, MockTransactionFactory, ErrorTransactionFactory) for testing transactions
pkg/router/config.go Add GlobalTransaction and TransactionFactory fields to RouterConfig for transaction management
pkg/common/types.go Define the TransactionFactory interface
pkg/common/config.go Introduce TransactionConfig, HasTransaction, and route-level overrides
pkg/router/integration_test.go Update integration tests to pass the new transaction argument
pkg/router/handler_func_coverage_test.go Add tests for handler-to-HandlerFunc conversion (missing type)
examples/... Update examples to include the extra nil transaction parameter
Comments suppressed due to low confidence (1)

pkg/router/handler_func_coverage_test.go:36

  • The type customHandler is not defined in this file, causing a compilation error. Define customHandler locally in this test or import it from another package.
customHandler := &customHandler{}

Comment on lines +22 to +23
m.BeginCount++
m.mu.Unlock()
Copy link

Copilot AI Jun 9, 2025

Choose a reason for hiding this comment

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

[nitpick] Consider using defer m.mu.Unlock() immediately after locking to ensure the mutex is always released, even if the function is extended in the future.

Suggested change
m.BeginCount++
m.mu.Unlock()
defer m.mu.Unlock()
m.BeginCount++

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants