Open
Description
Problem
The extensive use of manually-written dummy
mock objects (e.g., dummyMetadataRepository
, dummyStorageNodeClientFactory
, dummyStorageNodeClient
) across pkg/varlog/metarepos
and related package tests is a significant source of complexity and a bottleneck for development.
These dummy
objects present several problems:
- Overly complex: They mimic substantial internal logic of real components, including state management and asynchronous behavior (via channels), making tests hard to understand and debug.
- Hard to maintain: Changes to
dummy
objects can have widespread, unintended consequences across numerous tests. - Error-prone: The complexity of
dummy
objects themselves can introduce bugs into the tests. - Inconsistent: They deviate from standard mocking practices (like
gomock
), increasing the learning curve for new contributors. - Blurring test boundaries: Many tests using these mocks have become de-facto integration tests, losing the focus of unit testing.
This situation severely impacts developer productivity, making it difficult to write, understand, and modify tests efficiently.
Goals
The primary goal is to refactor these tests to improve clarity, maintainability, and developer productivity. We aim to:
- Replace
dummy
objects withgomock
: Transition togomock
for clear, interface-based mocking in unit tests. - Simplify unit tests: Focus unit tests on specific functions/methods with minimal, well-defined mock setups.
- Redesign and isolate integration tests: Separate tests verifying interactions between multiple components into dedicated integration tests. These should use real component instances or minimal, well-defined test helpers.
- Improve test readability: Make tests easier to understand by removing unnecessary complexity.
Metadata
Metadata
Assignees
Labels
No labels