Skip to content
New issue

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

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

Already on GitHub? # to your account

Refactor TestBasicAuth to utilize table-driven test format #2688

Merged
merged 2 commits into from
Oct 26, 2024

Conversation

ErikOlson
Copy link

@ErikOlson ErikOlson commented Oct 17, 2024

Summary

This PR refactors the basic_auth_test.go file to use a table-driven test approach. The new structure improves readability, simplifies the addition of new test cases, and makes it easier to maintain the tests as the codebase evolves.

What was changed

  • Refactored individual test cases within TestBasicAuth into a table-driven test.
  • Moved repeated logic into the test table to reduce redundancy.
  • No changes were made to production code.

Why the change was made

Table-driven tests provide a more scalable way to manage and add test cases. This refactor ensures that future test cases can be added with minimal repetition.

How it was tested

  • From the 'middleware' directory, ran go test -v -run TestBasicAuth. All tests passed successfully.
  • Manually checked each test within TestBasicAuth to ensure that if test conditions were changed the test failed.
  • No functional changes were made to the codebase, so there should be no impact on production.

Follow on

Am willing to refactor more tests if the table-driven format is desirable

@aldas aldas merged commit 5a0b4dd into labstack:master Oct 26, 2024
14 checks passed
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants