Skip to content

test: refactor TestBasicCredentials using table-driven tests #3406

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

iamamirsalehi
Copy link
Contributor

@iamamirsalehi iamamirsalehi commented Jun 14, 2025

Summary

This PR refactors the TestBasicCredentials function to use a table-driven testing approach. The goal is to improve test clarity, reduce duplication, and make it easier to extend with new cases in the future.


Changes

  • ✅ Refactored TestBasicCredentials to table-driven format
  • ✅ Combined basic auth and raw credentials checks under unified inputs
  • ✅ Preserved all existing logic including the empty username case
  • ✅ Replaced t.Fatalf with t.Errorf to allow multiple assertion failures per test run

Motivation

Table-driven tests are idiomatic in Go and make it easier to:

  • Maintain and scale tests
  • Add edge cases (e.g., empty password, special characters)
  • Keep tests concise and DRY

Notes

Also included additional edge cases such as:

  • Empty passwords
  • Special characters
  • Long strings
  • Unicode characters

- Empty passwords
- Special characters
- Long strings
- Unicode characters
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