On Sat, 3 Aug 2019 22:35:44 -0700 (PDT)
Andrey Tcherepanov <[email protected]> wrote:
> what if you need only a subpart of the package to be mocked ?
import smthorig "smth"
type smthT struct{
//functions
f1 func signature
f2 func signature
}
// functions
func mof1 (in...) (out...) { /* here your mock goes */ }
func mof2 (in...) (out...) { return smthorig(in...) }
var smth = smthT{ f1: mof1, f2: mof2 }
// methods
func (o smth) m1 (in...) (out...) { /* here your mock goes */ }
func (o smth) m2 (in...) (out...) { return smthorig(in...) }
Types are aliased
interfaces should be used from smthorig intact
Beware of packages that have init and keep state.
Hope this helps.
--
Wojciech S. Czarnecki
<< ^oo^ >> OHIR-RIPE
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/golang-nuts/20190804140657.4af7792a%40zuzia.