echo icon indicating copy to clipboard operation
echo copied to clipboard

Refactor TestBasicAuth to utilize table-driven test format

Open ErikOlson opened this issue 4 months ago • 0 comments

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

ErikOlson avatar Oct 17 '24 00:10 ErikOlson