internal/frontend: remove arbitrary test timeouts

Change-Id: I748daf2844982e6eec06212055ae4bdac7f7b211
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/521655
Reviewed-by: Robert Findley <rfindley@google.com>
kokoro-CI: kokoro <noreply+kokoro@google.com>
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
diff --git a/internal/frontend/directory_test.go b/internal/frontend/directory_test.go
index 5f9a6e7..e802c31 100644
--- a/internal/frontend/directory_test.go
+++ b/internal/frontend/directory_test.go
@@ -15,8 +15,7 @@
 )
 
 func TestGetNestedModules(t *testing.T) {
-	ctx, cancel := context.WithTimeout(context.Background(), testTimeout)
-	defer cancel()
+	ctx := context.Background()
 	fds := fakedatasource.New()
 
 	for _, m := range []*internal.Module{
diff --git a/internal/frontend/fetchserver/404_test.go b/internal/frontend/fetchserver/404_test.go
index a087613..7882b5e 100644
--- a/internal/frontend/fetchserver/404_test.go
+++ b/internal/frontend/fetchserver/404_test.go
@@ -287,8 +287,7 @@
 // Sometimes redirection sets the AlternativeModuleFlash cookie and puts
 // up a banner.
 func TestServer404Redirect(t *testing.T) {
-	ctx, cancel := context.WithTimeout(context.Background(), testTimeout)
-	defer cancel()
+	ctx := context.Background()
 
 	defer postgres.ResetTestDB(testDB, t)
 	sampleModule := sample.DefaultModule()
@@ -395,8 +394,7 @@
 }
 
 func TestServer404Redirect_NoLoop(t *testing.T) {
-	ctx, cancel := context.WithTimeout(context.Background(), testTimeout)
-	defer cancel()
+	ctx := context.Background()
 
 	altPath := "module.path/alternative"
 	goModPath := "module.path/alternative/pkg"
@@ -451,8 +449,7 @@
 }
 
 func TestEmptyDirectoryBetweenNestedModulesRedirect(t *testing.T) {
-	ctx, cancel := context.WithTimeout(context.Background(), testTimeout)
-	defer cancel()
+	ctx := context.Background()
 	defer postgres.ResetTestDB(testDB, t)
 
 	postgres.MustInsertModule(ctx, t, testDB, sample.Module(sample.ModulePath, sample.VersionString, ""))
diff --git a/internal/frontend/fetchserver/frontend_test.go b/internal/frontend/fetchserver/frontend_test.go
index ab13c12..d93a071 100644
--- a/internal/frontend/fetchserver/frontend_test.go
+++ b/internal/frontend/fetchserver/frontend_test.go
@@ -7,7 +7,6 @@
 import (
 	"context"
 	"testing"
-	"time"
 
 	"golang.org/x/pkgsite/internal"
 	"golang.org/x/pkgsite/internal/postgres"
@@ -15,8 +14,6 @@
 	"golang.org/x/pkgsite/internal/testing/sample"
 )
 
-const testTimeout = 5 * time.Second
-
 var testDB *postgres.DB
 
 func TestMain(m *testing.M) {
diff --git a/internal/frontend/fetchserver/server_test.go b/internal/frontend/fetchserver/server_test.go
index 69c998d..1654a67 100644
--- a/internal/frontend/fetchserver/server_test.go
+++ b/internal/frontend/fetchserver/server_test.go
@@ -1091,8 +1091,7 @@
 }
 
 func testServer(t *testing.T, testCases []serverTestCase) {
-	ctx, cancel := context.WithTimeout(context.Background(), testTimeout)
-	defer cancel()
+	ctx := context.Background()
 	defer postgres.ResetTestDB(testDB, t)
 
 	insertTestModules(ctx, t, testModules)
diff --git a/internal/frontend/frontend_test.go b/internal/frontend/frontend_test.go
index 7908ce3..c43257b 100644
--- a/internal/frontend/frontend_test.go
+++ b/internal/frontend/frontend_test.go
@@ -23,8 +23,6 @@
 	thirdparty "golang.org/x/pkgsite/third_party"
 )
 
-const testTimeout = 5 * time.Second
-
 type testModule struct {
 	path            string
 	redistributable bool
diff --git a/internal/frontend/imports_test.go b/internal/frontend/imports_test.go
index 3de1128..bef1934 100644
--- a/internal/frontend/imports_test.go
+++ b/internal/frontend/imports_test.go
@@ -46,8 +46,7 @@
 		t.Run(test.name, func(t *testing.T) {
 			fds := fakedatasource.New()
 
-			ctx, cancel := context.WithTimeout(context.Background(), testTimeout)
-			defer cancel()
+			ctx := context.Background()
 
 			module := sample.Module(sample.ModulePath, sample.VersionString, sample.Suffix)
 			// The first unit is the module and the second one is the package.
@@ -72,8 +71,7 @@
 
 func TestFetchImportedByDetails(t *testing.T) {
 	fds := fakedatasource.New()
-	ctx, cancel := context.WithTimeout(context.Background(), testTimeout)
-	defer cancel()
+	ctx := context.Background()
 
 	newModule := func(modPath string, pkgs ...*internal.Unit) *internal.Module {
 		m := sample.Module(modPath, sample.VersionString)
@@ -143,8 +141,7 @@
 
 func TestFetchImportedByDetails_ExceedsLimit(t *testing.T) {
 	fds := fakedatasource.New()
-	ctx, cancel := context.WithTimeout(context.Background(), testTimeout)
-	defer cancel()
+	ctx := context.Background()
 
 	old := importedByLimit
 	importedByLimit = 3
diff --git a/internal/frontend/search_test.go b/internal/frontend/search_test.go
index 4746a78..abb1661 100644
--- a/internal/frontend/search_test.go
+++ b/internal/frontend/search_test.go
@@ -231,8 +231,7 @@
 }
 
 func TestFetchSearchPage(t *testing.T) {
-	ctx, cancel := context.WithTimeout(context.Background(), testTimeout)
-	defer cancel()
+	ctx := context.Background()
 	fds := fakedatasource.New()
 
 	var (
@@ -514,9 +513,7 @@
 func TestSearchRequestRedirectPath(t *testing.T) {
 	// Experiments need to be set in the context, for DB work, and as
 	// a middleware, for request handling.
-	ctx, cancel := context.WithTimeout(context.Background(), testTimeout)
-
-	defer cancel()
+	ctx := context.Background()
 
 	golangTools := sample.Module("golang.org/x/tools", sample.VersionString, "internal/lsp")
 	std := sample.Module("std", sample.VersionString,