Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(410)

Issue 12018043: Spit and polish on fake roundtrippers. (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
10 years, 9 months ago by jtv.canonical
Modified:
10 years, 9 months ago
Reviewers:
dimitern, mp+177338, rvb
Visibility:
Public.

Description

Spit and polish on fake roundtrippers. We have a facility to inject fake HTTP interactions in tests, but it's harder to figure out and use than I think it needs to be. This branch: * Renames VirtualRoundTripper to CannedRoundTripper, to reflect more specifically that it returns canned responses. Still not great. * Replaces the slice-of-structs-of-name-and-value way in which the roundtripper stores canned responses with a simpler map-of-names-to-contents. * Hides the details of how a roundtripper is installed inside a helper function. * Documents how all this works, and in particular, a few nasty gotchas w.r.t. how conflicting matches are handled. * Extracts a factory for HTTP responses. I think it brings out the logic in the caller more clearly, eliminating some repetition along the way. * Gives me personally the chance to learn about a mechanism I'll be using next. https://code.launchpad.net/~jtv/juju-core/encapsulate-proxyroundtripper/+merge/177338 (do not edit description out of merge proposal)

Patch Set 1 #

Total comments: 13

Patch Set 2 : Spit and polish on fake roundtrippers. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+124 lines, -99 lines) Patch
A [revision details] View 1 1 chunk +2 lines, -0 lines 0 comments Download
M cmd/jujud/bootstrap_test.go View 1 2 chunks +4 lines, -5 lines 0 comments Download
M environs/ec2/export_test.go View 6 chunks +13 lines, -14 lines 0 comments Download
M environs/ec2/local_test.go View 1 chunk +3 lines, -3 lines 0 comments Download
M environs/imagemetadata/simplestreams_test.go View 4 chunks +8 lines, -9 lines 0 comments Download
M environs/jujutest/metadata.go View 1 2 chunks +75 lines, -47 lines 0 comments Download
M environs/jujutest/metadata_test.go View 2 chunks +6 lines, -8 lines 0 comments Download
M environs/openstack/export_test.go View 2 chunks +7 lines, -7 lines 0 comments Download
M environs/openstack/local_test.go View 2 chunks +6 lines, -6 lines 0 comments Download

Messages

Total messages: 7
jtv.canonical
Please take a look.
10 years, 9 months ago (2013-07-29 09:15:29 UTC) #1
dimitern
Very nice! LGTM with a bunch of trivial suggestions below https://codereview.appspot.com/12018043/diff/1/cmd/jujud/bootstrap_test.go File cmd/jujud/bootstrap_test.go (right): https://codereview.appspot.com/12018043/diff/1/cmd/jujud/bootstrap_test.go#newcode53 ...
10 years, 9 months ago (2013-07-29 10:02:35 UTC) #2
dimitern
Very nice! LGTM with a bunch of trivial suggestions below https://codereview.appspot.com/12018043/diff/1/cmd/jujud/bootstrap_test.go File cmd/jujud/bootstrap_test.go (right): https://codereview.appspot.com/12018043/diff/1/cmd/jujud/bootstrap_test.go#newcode53 ...
10 years, 9 months ago (2013-07-29 10:02:35 UTC) #3
rvb
LGTM [0] 220 +// ProxyRoundTripper is a RoundTripper Might be worth replacing RoundTripper with http.RoundTripper ...
10 years, 9 months ago (2013-07-29 10:14:02 UTC) #4
jtv.canonical
On 2013/07/29 10:02:35, dimitern wrote: > https://codereview.appspot.com/12018043/diff/1/cmd/jujud/bootstrap_test.go#newcode53 > cmd/jujud/bootstrap_test.go:53: testRoundTripper.Sub = > jujutest.NewCannedRoundTripper(map[string]string{ > Can ...
10 years, 9 months ago (2013-07-29 10:33:18 UTC) #5
jtv.canonical
Please take a look.
10 years, 9 months ago (2013-07-29 10:36:03 UTC) #6
jtv.canonical
10 years, 9 months ago (2013-07-29 10:40:57 UTC) #7
On 2013/07/29 10:14:02, rvb wrote:

> 220	+// ProxyRoundTripper is a RoundTripper
> 
> Might be worth replacing RoundTripper with http.RoundTripper to make it clear
> this is the interface from the std library you're talking about.

Thanks.  Done.


> I second Dimiter's suggestion to introduce a Disable() or a Unregister()
method.
>  It will make things more simple to understand and use.

Leaving that additional improvement for a future gardener, since I have a
feeling that a much more radical simplification could be in the cards.
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b