Skip to content

Add tests for critical coverage gaps#57

Closed
tedsmitt wants to merge 1 commit into
mainfrom
devin/1768415419-add-critical-test-coverage
Closed

Add tests for critical coverage gaps#57
tedsmitt wants to merge 1 commit into
mainfrom
devin/1768415419-add-critical-test-coverage

Conversation

@tedsmitt
Copy link
Copy Markdown
Owner

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:

  • TestGetContainerPort in aws_test.go - Tests port retrieval from task definitions with single/multiple containers and error handling
  • TestCreateOpts and TestInputLocalPort in new select_test.go - Tests the helper functions for building selection options
  • TestExecuteForwardRequiresRealClient in forward_test.go - Documents that executeForward cannot be properly unit tested due to a type assertion to *ecs.Client on line 33
  • TestPreRunEValidation and TestGetVersion in new cmd/main_test.go - Tests CLI argument validation logic

Review & Testing Checklist for Human

  • Review forward_test.go: The test documents a design limitation - executeForward() does a type assertion e.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.
  • Verify 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.
  • Run go test ./... -v locally to confirm all tests pass in your environment

Notes

  • No production code was modified, only test files added
  • Tests follow existing patterns and mock structures already in the codebase
  • The executeForward function 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)

- 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>
@tedsmitt
Copy link
Copy Markdown
Owner Author

Testing Devin out for a friend, closing.

@tedsmitt tedsmitt closed this Jan 14, 2026
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.

1 participant