qur / withmock

Automatic Go package mock generation tool
Other
71 stars 9 forks source link

Panic thrown with function literals #12

Closed imosquera closed 10 years ago

imosquera commented 10 years ago

I've noticed that you throw a Panic for function literals here because you still have work to finish: https://github.com/qur/withmock/blob/master/lib/mock.go#L184

this stops me from stubbing out functions during my tests since it needlessly throws the Panic. Can we remove the panic for now and add in functionality later?

qur commented 10 years ago

Not really. The panic is there to make sure that the code compiles. If I remove it then any function literal that is supposed to return a value won't compile.

My thinking behind using panic was that for any public variable you can just set it to something more sensible in your test code, and for private ones it will never get called anyway.

imosquera commented 10 years ago

Oh okay, I think that makes sense. The only reason it was failing was because I didn't re-assign that function. I'll give it a go soon.

imosquera commented 10 years ago

This is good now. Thanks for the heads up