Skip to content

test(utils): add table-driven unit tests for pure helper functions - #4493

Open
SatyamPandey-07 wants to merge 3 commits into
keploy:mainfrom
SatyamPandey-07:test/utils-unit-tests
Open

test(utils): add table-driven unit tests for pure helper functions #4493
SatyamPandey-07 wants to merge 3 commits into
keploy:mainfrom
SatyamPandey-07:test/utils-unit-tests

Conversation

@SatyamPandey-07

@SatyamPandey-07 SatyamPandey-07 commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Describe the changes that are made

  • Added table-driven unit test coverage in utils/utils_test.go for multiple pure helper functions in utils/utils.go:
    • TestIsShutdownError: tests EOF, connection reset, broken pipe, closed network connection patterns, and error exclusion.
    • TestReplaceHost: tests URL host replacement, invalid URLs, and empty IP edge cases.
    • TestReplaceGrpcHost & TestReplaceGrpcPort: tests authority parsing and port/host replacement with error handling.
    • TestReplaceBaseURL: tests URL base replacement and empty/invalid base URLs.
    • TestReplacePort: tests adding port when missing, replacing existing port, and error handling.
    • TestToInt, TestToString, TestToFloat: tests type conversions across numeric types, json.Number, strings, and fallbacks.
    • TestKeys: tests map key slice extraction.
    • TestEnsureRmBeforeName: tests proper insertion of --rm before --name in Docker run commands without duplication.

Links & References

Closes #4491

🔗 Related PRs

  • NA

🐞 Related Issues

📄 Related Documents

  • NA

What type of PR is this? (check all applicable)

  • 📦 Chore
  • 🍕 Feature
  • 🐞 Bug Fix
  • 📝 Documentation Update
  • 🎨 Style
  • 🧑💻 Code Refactor
  • 🔥 Performance Improvements
  • ✅ Test
  • 🔁 CI
  • ⏩ Revert

Added e2e test pipeline?

  • 🙅 no, because they aren't needed

Added comments for hard-to-understand areas?

  • 🙅 no, because the code is self-explanatory

Added to documentation?

  • 🙅 no documentation needed

Are there any sample code or steps to test the changes?

  • 👍 yes, mentioned below

Run unit tests in the utils package:

go test -v ./utils

Self Review done?

  • ✅ yes

Any relevant screenshots, recordings or logs?

  • NA

Additional checklist:

… utils

Expands table-driven unit test coverage in utils/utils_test.go for pure helper functions including IsShutdownError, ReplaceHost, ReplaceGrpcHost, ReplaceGrpcPort, ReplaceBaseURL, ReplacePort, ToInt, ToString, ToFloat, Keys, and EnsureRmBeforeName.

Closes keploy#4491

Signed-off-by: Satyam Pandey <satyam53@tsecol.onmicrosoft.com>
@SatyamPandey-07 SatyamPandey-07 changed the title test(utils): add table-driven unit tests for pure helper functions in… test(utils): add table-driven unit tests for pure helper functions Aug 26, 2026
@github-actions

github-actions Bot commented Aug 26, 2026

Copy link
Copy Markdown

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

@github-actions

Copy link
Copy Markdown

The CLA check failed. Please ensure you have:

  • Signed the CLA by commenting 'I have read the CLA Document and I hereby sign the CLA'
  • Used the correct email address in your commits (matches the one you used to sign the CLA).

After fixing these issues, comment 'recheck' to trigger the workflow again.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thank you and congratulations 🎉 for opening your very first pull request in keploy

@SatyamPandey-07

Copy link
Copy Markdown
Contributor Author

I have read the CLA Document and I hereby sign the CLA

@SatyamPandey-07

Copy link
Copy Markdown
Contributor Author

recheck

@SatyamPandey-07

Copy link
Copy Markdown
Contributor Author

I have read the CLA Document and I hereby sign the CLA
recheck

1 similar comment
@SatyamPandey-07

Copy link
Copy Markdown
Contributor Author

I have read the CLA Document and I hereby sign the CLA
recheck

@SatyamPandey-07

Copy link
Copy Markdown
Contributor Author

@prabaltripathiofficial Hi, just bumping this PR in case it slipped through your notifications. Let me know if you need any changes or further testing!

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.

test(utils): add table-driven unit test coverage for pure helper functions in utils/utils.go

1 participant