2 ms·
Then the original code is perfectly fine and does not need refactoring. You create the mocks you need with cleanup defers and you're done. You could just make
by Mawr 5y ago
Then the original code is perfectly fine and does not need refactoring. You create the mocks you need with cleanup defers and you're done.
You could just make a function that creates all the mocks needed for all tests, but you don't like that. So the only option left is to specify which mocks you need for each test... which is exactly what the original code is doing.
You're running into a wall because you're trying to abstract code that's already maximally abstracted.