cache icon indicating copy to clipboard operation
cache copied to clipboard

Refactor `cache_test.go`

Open gozeloglu opened this issue 2 years ago • 0 comments

cache_test.go should be refactored to follow Go-style table-driven test.

Why was it written like that?

I was a newbie in Go while I was implementing this package.

Why is it important?

  • In the current version, test files are not maintainable and readable. It is really hard to make changes or add new test cases.
  • Go has some conventions like writing tests in a table-driven style. It will be better if the test functions are refactored for welcoming new contributors. Go developers are familiar with test style and it makes the project understandable for them.
  • It is hard to detect bugs now.

TODOs

  • [ ] Convert test functions to table-driven tests.
  • [ ] Keep test coverage rate.

Resources

  • https://dave.cheney.net/2019/05/07/prefer-table-driven-tests
  • https://go.dev/blog/subtests
  • https://semaphoreci.com/blog/table-driven-unit-tests-go
  • https://dev.to/boncheff/table-driven-unit-tests-in-go-407b

gozeloglu avatar Jul 19 '23 21:07 gozeloglu