Closed GoogleCodeExporter closed 9 years ago
Also maybe I'll elaborate a bit on the real life case where this struck me:
I have a function that I wish to test that takes a ptr to a struct as its sole
argument.
It's basically an "InitializeThisThingForMe" function that uses reflection for
convenience (saves me having to write a whole bunch of boilerplate NewThis()
and NewThat() functions for any number of future struct types).
The function needs to call an interface method on any and all of the struct
fields of types that implement a specific interface, regardless of whether the
field is an interface type, a pointer to a struct that implements this
interface or a struct value in-place.
The last of these is currently untestable using a gomock generated mock
interface.
Original comment by nick...@gmail.com
on 23 May 2015 at 11:18
Sorry, I can't really see what your probably is or proposed change is. It's
hard to discover that by looking at a clone. Can you make a diff and attach it
here?
Original comment by dsymo...@golang.org
on 25 May 2015 at 3:31
Hi, yep, no worries.
You can see all changes I made (I made only one commit after cloning) here:
https://code.google.com/r/nickmab-callsetpatch/source/detail?r=afb265f8533d70b78
6252a6c6da6b0e63f53ed94
3 of the changes are adding example files to demonstrate the point of the
change.
1 change is the actual change to callset.go, which I've attached here too.
Original comment by nick...@gmail.com
on 25 May 2015 at 6:18
Attachments:
If I understand the diff correctly, it's making it so that you can copy mock
objects, like what you do in callsetpatch_sample/mypkg_test.go?
If so, that's not a supported use case. In your sample, you should be calling
NewMockIExample for each mock object, not copying an existing value. Your
change would also break things if we ever needed to put something in a mock
object that wasn't a legal map value, since your change uses a struct as a map
key instead of a pointer to a struct.
Original comment by dsymo...@golang.org
on 26 May 2015 at 1:48
No worries at all, thanks for the patient explanation.
Original comment by nick...@gmail.com
on 26 May 2015 at 2:22
Original issue reported on code.google.com by
nick...@gmail.com
on 23 May 2015 at 11:06