[test] Add tests for launcher.GetOrLaunch#142
Closed
github-actions[bot] wants to merge 6 commits into
Closed
Conversation
- Add 14 test functions covering 50+ test cases - Test concurrent access patterns with RWMutex - Test double-check locking pattern - Test environment variable passthrough detection - Test container detection logic - Test error handling for server not found - Test context cancellation - Test edge cases (nil config, empty strings, etc.) - Expected coverage improvement: 0% -> ~75-85%
Collaborator
|
@copilot run tests |
Contributor
Collaborator
|
@copilot format, lint |
Contributor
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Test Coverage Improvement: launcher Package
Function Analyzed
internal/launcherNew(),GetOrLaunch(),ServerIDs(),Close()Why This Package?
The
launcherpackage was selected because:launcher_test.gocreated in this PR)GetOrLaunch()aloneTests Added
✅ 14 test functions covering 50+ individual test cases
Core Functionality Tests
Concurrency & Thread Safety Tests
Error Handling Tests
Feature-Specific Tests
TestGetOrLaunch_EnvironmentVariablePassthrough (5 cases)
-e VAR_NAME)-e VAR=value)TestGetOrLaunch_DirectCommandWarning (4 cases)
TestLauncher_ContainerDetection - Container runtime detection
TestNew_NilConfig - Defensive nil handling
Testing Patterns Used
Coverage Report
Before
Expected After
Untested Areas
The following areas require additional mocking infrastructure:
mcp.NewConnection()success path and connection storageThese would require:
mcp.NewConnection()Test Execution
To verify locally:
Files Changed
internal/launcher/launcher_test.go(610 lines, 14,170 bytes)Impact
This PR significantly improves test coverage for one of the most complex and critical packages in the codebase:
Generated by Test Coverage Improver Agent
Next recommended target:
internal/mcp/connection.go(0% coverage, high complexity)