aboutsummaryrefslogtreecommitdiff
path: root/internal/testing
diff options
context:
space:
mode:
authorMichael Matloob <matloob@golang.org>2023-08-28 13:39:03 -0400
committerMichael Matloob <matloob@golang.org>2023-08-29 23:29:11 +0000
commitebe617b30c52774fccf9d36331cbff31e99aaf9e (patch)
tree9b413e7ec61ce6a08e169d8ab95eb3bca1b1effc /internal/testing
parent6b2c42d38504a02ea8b77abc7c592b64aa39109d (diff)
downloadgo-x-pkgsite-ebe617b30c52774fccf9d36331cbff31e99aaf9e.tar.xz
internal/source: inject *http.Client into source.NewClient
This removes the dependency from package source onto ochttp. The users of source.NewClient that want an ochttp.Transport can set the transport on the *http.Client. For golang/go#61399 Change-Id: Ifb7126c482f664ee5a359f594d9324f0fd90f8b2 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/523510 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Robert Findley <rfindley@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Michael Matloob <matloob@golang.org> kokoro-CI: kokoro <noreply+kokoro@google.com>
Diffstat (limited to 'internal/testing')
-rw-r--r--internal/testing/integration/frontend_test.go4
-rw-r--r--internal/testing/integration/worker_test.go5
2 files changed, 4 insertions, 5 deletions
diff --git a/internal/testing/integration/frontend_test.go b/internal/testing/integration/frontend_test.go
index 4b660637..e9cbe997 100644
--- a/internal/testing/integration/frontend_test.go
+++ b/internal/testing/integration/frontend_test.go
@@ -88,7 +88,7 @@ func setupFrontend(ctx context.Context, t *testing.T, q queue.Queue, rc *redis.C
func setupQueue(ctx context.Context, t *testing.T, proxyModules []*proxytest.Module, experimentNames ...string) (queue.Queue, func()) {
cctx, cancel := context.WithCancel(ctx)
proxyClient, teardown := proxytest.SetupTestClient(t, proxyModules)
- sourceClient := source.NewClient(1 * time.Second)
+ sourceClient := source.NewClient(http.DefaultClient)
q := queue.NewInMemory(cctx, 1, experimentNames,
func(ctx context.Context, mpath, version string) (_ int, err error) {
return fetchserver.FetchAndUpdateState(ctx, mpath, version, proxyClient, sourceClient, testDB)
@@ -110,7 +110,7 @@ func processVersions(ctx context.Context, t *testing.T, testModules []*proxytest
}
func fetchAndInsertModule(ctx context.Context, t *testing.T, tm *proxytest.Module, proxyClient *proxy.Client) {
- sourceClient := source.NewClient(1 * time.Second)
+ sourceClient := source.NewClient(http.DefaultClient)
res := fetch.FetchModule(ctx, tm.ModulePath, tm.Version, fetch.NewProxyModuleGetter(proxyClient, sourceClient))
if res.Error != nil {
t.Fatal(res.Error)
diff --git a/internal/testing/integration/worker_test.go b/internal/testing/integration/worker_test.go
index 110a21b8..d6f75766 100644
--- a/internal/testing/integration/worker_test.go
+++ b/internal/testing/integration/worker_test.go
@@ -14,7 +14,6 @@ import (
"net/http"
"net/http/httptest"
"testing"
- "time"
"github.com/alicebob/miniredis/v2"
"github.com/go-redis/redis/v8"
@@ -34,7 +33,7 @@ func setupWorker(ctx context.Context, t *testing.T, proxyClient *proxy.Client, i
fetcher := &worker.Fetcher{
ProxyClient: proxyClient,
- SourceClient: source.NewClient(1 * time.Second),
+ SourceClient: source.NewClient(http.DefaultClient),
DB: testDB,
Cache: cache.New(redisCacheClient),
}
@@ -49,7 +48,7 @@ func setupWorker(ctx context.Context, t *testing.T, proxyClient *proxy.Client, i
DB: testDB,
IndexClient: indexClient,
ProxyClient: proxyClient,
- SourceClient: source.NewClient(1 * time.Second),
+ SourceClient: source.NewClient(http.DefaultClient),
RedisCacheClient: redisCacheClient,
Queue: queue,
StaticPath: template.TrustedSourceFromConstant("../../../static"),