Closed samuong closed 4 years ago
Years of being trained by tools like SonarQube (and similarly-programmed humans) has made me feel guilty every time I don't create a named constant. I've just changed this so that the delay is inline with the code, which I agree is easier to read, and doesn't result in a false sense of security about the consistency of the log message and the actual delay.
I've also added some more error checking. Previously the call to log.Printf()
could have been called with a nil error value. It was also possible that a retried download would leak a resp.Body
.
PTAL?
While thinking about your last comment, I realised that this PR adds about 6 seconds to the time taken to run the tests (it goes from less than half a second to over six seconds to run go test
). So I'm going to hold off on merging this, and I'm planning to make the 2 second sleep a parameter inside the pacFetcher
struct, and setting it to something else for unit tests.
@camh- I've fixed the tests, can you please take another look?
I can't think of a better way to fix issue #8. This should work around it in most, if not all, cases.