FAQ

How can I unit test a particular service if the db layer is tightly
coupled?
If I got your question right, then the solution is simple:

type DbAdapter interface {
// ...
}

Different implementations of DbAdapter can be written.
Your service's depend on DbAdapter's behaviour, not its implementation.
You can then unit-test your services by providing them with a
mocked DbAdapter.

In general, when writing Go, do it concretely and straightforwardly. Only
abstract when you have a need for generality.
Changing Go code from using a concrete type to an interface is fairly
simple and easy. Most of the time it requires no refraction.

Cheers!

--

Search Discussions

Discussion Posts

Previous

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 7 of 7 | next ›
Discussion Overview
groupgolang-nuts @
categoriesgo
postedSep 15, '12 at 11:16p
activeSep 17, '12 at 12:16a
posts7
users5
websitegolang.org

People

Translate

site design / logo © 2021 Grokbase