internal/proxydatasource: use testing source.Client

Use the testing version of the source.Client for tests.

Change-Id: Id4435bdedf4f9230f395eec6319e6f38cbc0774f
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/279798
Trust: Jonathan Amsterdam <jba@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Jamal Carvalho <jamal@golang.org>
Reviewed-by: Julie Qiu <julie@golang.org>
diff --git a/internal/proxydatasource/datasource.go b/internal/proxydatasource/datasource.go
index bf453b3..c377696 100644
--- a/internal/proxydatasource/datasource.go
+++ b/internal/proxydatasource/datasource.go
@@ -29,9 +29,17 @@
 
 // New returns a new direct proxy datasource.
 func New(proxyClient *proxy.Client) *DataSource {
+	return newDataSource(proxyClient, source.NewClient(1*time.Minute))
+}
+
+func NewForTesting(proxyClient *proxy.Client) *DataSource {
+	return newDataSource(proxyClient, source.NewClientForTesting())
+}
+
+func newDataSource(proxyClient *proxy.Client, sourceClient *source.Client) *DataSource {
 	return &DataSource{
 		proxyClient:          proxyClient,
-		sourceClient:         source.NewClient(1 * time.Minute),
+		sourceClient:         sourceClient,
 		versionCache:         make(map[versionKey]*versionEntry),
 		modulePathToVersions: make(map[string][]string),
 		packagePathToModules: make(map[string][]string),
diff --git a/internal/proxydatasource/datasource_test.go b/internal/proxydatasource/datasource_test.go
index fd4545b..bf52d1d 100644
--- a/internal/proxydatasource/datasource_test.go
+++ b/internal/proxydatasource/datasource_test.go
@@ -59,7 +59,7 @@
 	}
 	client, teardownProxy := proxy.SetupTestClient(t, testModules)
 	ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second)
-	return ctx, New(client), func() {
+	return ctx, NewForTesting(client), func() {
 		teardownProxy()
 		cancel()
 	}
@@ -236,7 +236,7 @@
 	defer teardownProxy()
 	ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
 	defer cancel()
-	ds := New(client)
+	ds := NewForTesting(client)
 
 	for _, test := range []struct {
 		fullPath        string