refactor(oohelperd): improve tests implementation (#835)

After this diff has landed, we have addressed all the points
originally published at https://github.com/ooni/probe/issues/2134.
This commit is contained in:
Simone Basso 2022-07-05 20:25:18 +02:00 committed by GitHub
commit d419ed8ac8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 186 additions and 168 deletions

View file

@ -9,6 +9,7 @@ import (
"github.com/google/go-cmp/cmp"
"github.com/ooni/probe-cli/v3/internal/model"
"github.com/ooni/probe-cli/v3/internal/model/mocks"
"github.com/ooni/probe-cli/v3/internal/netxlite"
)
@ -46,8 +47,13 @@ func TestHTTPDoWithHTTPTransportFailure(t *testing.T) {
MaxAcceptableBody: 1 << 24,
NewClient: func() model.HTTPClient {
return &http.Client{
Transport: FakeTransport{
Err: expected,
Transport: &mocks.HTTPTransport{
MockRoundTrip: func(req *http.Request) (*http.Response, error) {
return nil, expected
},
MockCloseIdleConnections: func() {
// nothing
},
},
}
},