Open patrik-bartak opened 2 months ago
To keep it simple I just copied the auto sync call before the local file is changed. The only drawback I see is that there are now two printouts. This is fine but might be confusing.
Yep I can do that
I'm new to open source so I'm happy to practice a bit on a smaller project
Let's say I want to test func AutoSync(file string)
that uses a sync Client
. I have two options: refactor to make Client
an argument, or using a mocking package like gomock. Is this right or am I missing something?
Yes exactly. You need to parametrize these dependencies, then you'll be able to replace them with your mocks. By making Client an argument, you can then bring in our own TestClient and pass that in instead and be able to test the logic without calling a real client! I would've linked a nice article on dependency inversion and injection, but I couldn't find one that wasn't worded in a complicated way, and I think you've got the idea honestly.
@patrik-bartak can i help with anything? are you stuck or something or just haven't had the time?
Issue #, if available:
57
Description of changes: Currently, snippets are lost when autosync is enabled and snippets are added from different machines. With this change, auto sync is called both before and after a new snippet is added to the local file. This means remote changes will not be overwritten.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.