Add tests for critical coverage gaps#57
Closed
tedsmitt wants to merge 1 commit into
Closed
Conversation
- Add tests for getContainerPort in aws_test.go (0% -> 100%) - Add tests for createOpts and inputLocalPort in select_test.go - Add tests for executeForward in forward_test.go (documents type assertion limitation) - Add CLI validation tests in cmd/main_test.go (PreRunE and getVersion) Overall coverage improved from 37.4% to 45.3% Co-Authored-By: Ed Smith <ed@edintheclouds.io>
Owner
Author
|
Testing Devin out for a friend, closing. |
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.
Summary
This PR adds unit tests for functions that previously had 0% test coverage, improving overall test coverage from 37.4% to 45.3%.
New tests added:
TestGetContainerPortinaws_test.go- Tests port retrieval from task definitions with single/multiple containers and error handlingTestCreateOptsandTestInputLocalPortin newselect_test.go- Tests the helper functions for building selection optionsTestExecuteForwardRequiresRealClientinforward_test.go- Documents thatexecuteForwardcannot be properly unit tested due to a type assertion to*ecs.Clienton line 33TestPreRunEValidationandTestGetVersionin newcmd/main_test.go- Tests CLI argument validation logicReview & Testing Checklist for Human
forward_test.go: The test documents a design limitation -executeForward()does a type assertione.client.(*ecs.Client)which prevents mocking. The test expects and catches this panic. Consider if this is acceptable or if the production code should be refactored to use the interface.TestInputLocalPort: This test relies on the existing test-mode check (flag.Lookup("test.v")) which returns hardcoded "42069". It tests the test-mode path, not actual user input.go test ./... -vlocally to confirm all tests pass in your environmentNotes
executeForwardfunction would need refactoring to be properly testable (remove the type assertion to concrete*ecs.Client)Link to Devin run: https://app.devin.ai/sessions/e2c116ced07146ffa9443dfddb14c76f
Requested by: Ed Smith (@tedsmitt)