refactor(engine): *http.Client -> model.HTTPClient (#836)

This diff makes the implementation of the engine package more
abstract by changing HTTPClient() to return a model.HTTPClient
as opposed to returning an *http.Client.

Part of https://github.com/ooni/probe/issues/2184
This commit is contained in:
Simone Basso
2022-07-08 11:08:10 +02:00
committed by GitHub
parent d419ed8ac8
commit 6019b25baf
5 changed files with 10 additions and 9 deletions
+2 -3
View File
@@ -3,7 +3,6 @@ package mockable
import (
"context"
"net/http"
"net/url"
"github.com/ooni/probe-cli/v3/internal/engine/probeservices"
@@ -14,7 +13,7 @@ import (
// Session allows to mock sessions.
type Session struct {
MockableTestHelpers map[string][]model.OOAPIService
MockableHTTPClient *http.Client
MockableHTTPClient model.HTTPClient
MockableLogger model.Logger
MockableMaybeResolverIP string
MockableProbeASNString string
@@ -45,7 +44,7 @@ func (sess *Session) GetTestHelpersByName(name string) ([]model.OOAPIService, bo
}
// DefaultHTTPClient implements ExperimentSession.DefaultHTTPClient
func (sess *Session) DefaultHTTPClient() *http.Client {
func (sess *Session) DefaultHTTPClient() model.HTTPClient {
return sess.MockableHTTPClient
}