Thanks, @xuu@txt.sour.is, great explanation. In another project I’ve structured it exactly like you wrote. The mock storage over there extends the SQLite storage and provides mechanism to return errors and such for testing purposes:
- storage/ defines the interface
- sqlite/ implements the storage interface
- mock/ extends the SQLite implementation by some mocking capabilities and assertions
- sqlite/ implements the storage interface
Here, however, there are no storage subpackages. It’s just storage
, that’s it. Everything is in there. The only implementation so far is an SQLite backend that resides in storage
. My RAM storage is exactly that SQLite storage, but with :memory:
instead a backing file on disk. I do not have a mock storage (yet).
I have to think about it a bit more, but I probably have to do exactly that in my tt
rewrite, too. Sigh. I just have the feeling that in storage/sqlite/sqlite_test.go I cannot import storage/mock for the helper because storage/mock/mock.go imports and embeds the type from storage/sqlite. But I’m too tired right now to think clearly.