You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A useful pattern is to have a function take a thing that doesn't implement an interface and return anotherThing that does. These glue functions work really well to connect different parts of an application, and create a useful abstraction across interfaces.
The way I test these functions is with assert.Implements(t, interface, anotherThing) on the result of the function, and _, ok := thing.(interface); assert.False(ok) on the input for good measure.
It would be oh so convenient if there were an assert.NotImplements(t, interface, thing) I could run instead, and it would be fairly trivial to add to the API as it stands. If this isn't the kind of change that's likely to happen, is there a more semantically reasonable way of doing this?
The text was updated successfully, but these errors were encountered:
A useful pattern is to have a function take a
thing
that doesn't implement an interface and returnanotherThing
that does. These glue functions work really well to connect different parts of an application, and create a useful abstraction across interfaces.The way I test these functions is with
assert.Implements(t, interface, anotherThing)
on the result of the function, and_, ok := thing.(interface); assert.False(ok)
on the input for good measure.It would be oh so convenient if there were an
assert.NotImplements(t, interface, thing)
I could run instead, and it would be fairly trivial to add to the API as it stands. If this isn't the kind of change that's likely to happen, is there a more semantically reasonable way of doing this?The text was updated successfully, but these errors were encountered: