stakwork / sphinx-tribes

Backend for sphinx tribes and bounties. The bounty platform pays out in bitcoin. Sign up with Sphinx Chat, complete a bounty, and earn bitcoin! Go to our website for available bounties.
https://community.sphinx.chat/bounties
33 stars 60 forks source link

Auto mock db #1214

Closed kevkevinpal closed 9 months ago

kevkevinpal commented 9 months ago
          On a different topic @kevkevinpal  can i do some refactoring of the handlers to make it more testable ? **if i get assigned this bounty** . 

Mainly would keep all the handler functions behind a struct and inject httpClient to it, making it much more easier to replace it with mockClient at the test. Something like this handler.go.

In the future can create an interface for DB and inject it in the handler thereby making the handler unit much more testable. Can use mockery to auto generate mocks to cover all scenario and inject the mocks in tests thereby reducing our error to create mock functions and all.

Just a thought.

Originally posted by @wright-eric in https://github.com/stakwork/sphinx-tribes/issues/1208#issuecomment-1872173900

ecurrencyhodler commented 9 months ago

@wright-eric would you be open to addressing this issue? I created a bounty for 400k. https://community.sphinx.chat/bounty/1031

wright-eric commented 9 months ago

Yes absolutely