go-tarantool icon indicating copy to clipboard operation
go-tarantool copied to clipboard

v3: use interface instead of `*testing.T` in `test_helpers`

Open bigbes opened this issue 1 month ago • 0 comments

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.T contexts (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 T interface in test_helpers (e.g., in test_helpers/types.go).
  • [ ] Update all helper functions and structs (MockDoer, MockResponse, etc.) to use T.
  • [ ] Update existing tests to still pass *testing.T (it satisfies T automatically).
  • [ ] Modify CHANGELOG.md and MIGRATION.md accordingly

bigbes avatar Oct 24 '25 08:10 bigbes