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

Merged
merged 2 commits into from
Jun 16, 2025

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
Copy link
Member

@ndyakov ndyakov left a comment

Choose a reason for hiding this comment

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

@iamamirsalehi thank you for the contribution!

@ndyakov ndyakov merged commit e2295c7 into redis:master Jun 16, 2025
16 checks passed
@iamamirsalehi iamamirsalehi deleted the test/improve-basic-credentials branch June 17, 2025 15:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
2 participants