Skip to content

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants