go-tarantool
go-tarantool copied to clipboard
v3: use interface instead of `*testing.T` in `test_helpers`
Refactor the test_helpers package to accept a custom T interface instead of concrete *testing.T. This makes test utilities reusable in examples, benchmarks, or custom test runners.
Types like MockDoer and MockResponse depend directly on *testing.T:
func NewMockDoer(t *testing.T, ...) *MockDoer
This tightly couples helpers to the testing package, preventing their use in:
- Example functions (
ExampleXxx) - Custom test frameworks
- Non-
*testing.Tcontexts (e.g., internal validation tools)
Define a minimal interface that captures only the methods we actually use:
// T is a subset of *testing.T used for test helpers.
type T interface {
Helper()
Fatalf(format string, args ...interface{})
Errorf(format string, args ...interface{})
}
Then update all functions in test_helpers to accept T instead of *testing.T.
Checklist
- [ ] Add the
Tinterface intest_helpers(e.g., intest_helpers/types.go). - [ ] Update all helper functions and structs (
MockDoer,MockResponse, etc.) to useT. - [ ] Update existing tests to still pass
*testing.T(it satisfiesTautomatically). - [ ] Modify CHANGELOG.md and MIGRATION.md accordingly