State interfaces
roger peppe
rogpeppe at gmail.com
Thu Oct 31 13:24:31 UTC 2013
On 31 October 2013 05:21, Andrew Wilkins <andrew.wilkins at canonical.com> wrote:
> Does anybody object to converting the public entity structs in state to
> interfaces? i.e. State, Machine, Unit, etc.
>
> I'd like to write some tests for new code that depends on state. Setting up
> mongo and so on is overkill. and should be relegated to integration testing.
If State was an interface, it alone would have 45 methods, not
counting 190 more in Machine, Unit, etc; this seems really quite unwieldy.
It certainly wouldn't be easy to implement a mock implementation without using
the original.
Without knowing more about your particular problem I can't say
much more, but John's suggestion seems sound and is one I've
been using recently (see worker/addressupdater for example) -
inventing ad hoc interfaces that describe the local needs of the importer,
rather than providing giant interfaces that try to be all things to
all users.
cheers,
rog.
More information about the Juju-dev
mailing list