MockPackage()
Nate Finch
nate.finch at canonical.com
Tue Mar 4 16:22:42 UTC 2014
This is kind of why I made MockPackage, one of those "if there's something
you don't want people to use, make it ugly".
If you really want to expose a knob, it's either a public variable or
get/set functions. I don't know of a third way. The nice thing about
get/set is that it at least sort of hides the value, so people will be less
likely to hardcode assumptions about it.... the Set function also makes it
a little more obvious you're doing something unusual, rather than assigning
a value which can be easy to overlook.
I don't know... if someone has a better idea, I'm all ears.
On Tue, Mar 4, 2014 at 7:30 AM, John Meinel <john at arbash-meinel.com> wrote:
> honestly, http.DefaultClient is a case of global state that too many
> people touch, and I'd be happier to avoid them.
>
> On Tue, Mar 4, 2014 at 1:58 PM, roger peppe <rogpeppe at gmail.com> wrote:
> > On 3 March 2014 17:49, Nate Finch <nate.finch at canonical.com> wrote:
> >> John talked to me on a hangout and suggested that, often times, when you
> >> need to expose something like this for tests, it ends up being something
> >> that production code needs to tweak as well. He'd like to see something
> >> better than a public variable, but didn't offer a suggestion as to what.
> >>
> >> I think this is a pretty good point, so I'll try to come up with a
> third way
> >> that isn't too cumbersome.
> >
> > I think a public variable is actually OK. We don't actually have to
> stipulate
> > that it should only be changed for testing, and the global nature of
> > should make it clear that it should not be changed other than at init
> time.
> >
> > It's a pretty standard Go idiom to do this (see http.DefaultClient,
> > for example).
> >
> > --
> > Juju-dev mailing list
> > Juju-dev at lists.ubuntu.com
> > Modify settings or unsubscribe at:
> https://lists.ubuntu.com/mailman/listinfo/juju-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/juju-dev/attachments/20140304/375a7fb9/attachment.html>
More information about the Juju-dev
mailing list