feat(httpx): improve testing using the fakefiller (#649)

This diff extracts the fakefiller inside of internal/ooapi (a
currently unused package) into its own package.

The fakefiller knows how to fill many fields that are typically
shared as data structures across processes.

It is not perfect in that it cannot fill logger or http client
fields, but still helps with better filling and testing.

So, here we're using the fakefiller to improve testing of httpx
and, nicely enough, we've already catched a bug in the way in
which APIClientTemplate.Build misses to forward Authorization from
the original template. Yay!

Work part of https://github.com/ooni/probe/issues/1951
This commit is contained in:
Simone Basso 2022-01-05 14:49:31 +01:00 committed by GitHub
commit 93f084598e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
24 changed files with 433 additions and 337 deletions

View file

@ -42,7 +42,7 @@ type APIClientTemplate struct {
// Build creates an APIClient from the APIClientTemplate.
func (tmpl *APIClientTemplate) Build() APIClient {
return tmpl.BuildWithAuthorization("")
return tmpl.BuildWithAuthorization(tmpl.Authorization)
}
// BuildWithAuthorization creates an APIClient from the