alphagov/cdn-acceptance-tests — pull request #52 by dcarley (2014-06-19 14:49:07+00:00)
Title: [Fixes #37] Request helpers

#### RoundTripCheckError helper

Move all calls to `client.RoundTrip` into a helper function. This reduces
our use of the `client` global variable and the repetition of checking
request errors. It also gives us a handy place to document why we're using
`RoundTrip` instead of `Do` or `Get`.

#### NewUniqueEdgeGET helper

Because:

- We do a lot of creating `http.Request` without checking errors. Which is
dangerous, as Mike found out, because we'll get a nil object if there's a
problem with the URL and cause `client.RoundTrip` to panic.
- It reduces our use of the global pointer variable `*edgeHost`.
- Standardises the URL pattern to always be a query param. Which will allow
more tests to work against production, but shouldn't affect their existing
behaviour.

There are two instances where I'm modifying the request method on the object
returned by NewUniqueEdgeGET. Which, despite the name, I think is OK.
Because it's still quite clear what they're doing and it's better than them
being vastly different.

There are also two instances that aren't using the helper because they
currently use the UUID to construct the response handler.