internal/fetch: reorganize testdata directory

The modcache subdirectory did not correctly resemble a true module
cache. Move the proxy part into a cache/download subdirectory, and
expand one module zip, since we'll be serving source from the expanded
files, not the zip.

For golang/go#47982

Change-Id: Ib5d49f67d2e7a47f8763958d28f44861aea9296b
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/347929
Trust: Jonathan Amsterdam <jba@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Julie Qiu <julie@golang.org>
diff --git a/cmd/pkgsite/main_test.go b/cmd/pkgsite/main_test.go
index afce39e..1c233f8 100644
--- a/cmd/pkgsite/main_test.go
+++ b/cmd/pkgsite/main_test.go
@@ -21,7 +21,7 @@
 	repoPath := func(fn string) string { return filepath.Join("..", "..", fn) }
 
 	localModule := repoPath("internal/fetch/testdata/has_go_mod")
-	cacheDir := repoPath("internal/fetch/testdata/modcache")
+	cacheDir := repoPath("internal/fetch/testdata/modcache/cache/download")
 	flag.Set("static", repoPath("static"))
 	testModules := proxytest.LoadTestModules(repoPath("internal/proxy/testdata"))
 	prox, teardown := proxytest.SetupTestClient(t, testModules)
diff --git a/internal/fetch/getters_test.go b/internal/fetch/getters_test.go
index aa99ae2..997b6b6 100644
--- a/internal/fetch/getters_test.go
+++ b/internal/fetch/getters_test.go
@@ -68,7 +68,7 @@
 	if err != nil {
 		t.Fatal(err)
 	}
-	g := NewFSProxyModuleGetter("testdata/modcache")
+	g := NewFSProxyModuleGetter("testdata/modcache/cache/download")
 	t.Run("info", func(t *testing.T) {
 		got, err := g.Info(ctx, modulePath, vers)
 		if err != nil {
diff --git a/internal/fetch/testdata/modcache/github.com/jackc/pgio/@v/v1.0.0.info b/internal/fetch/testdata/modcache/cache/download/github.com/jackc/pgio/@v/v1.0.0.info
similarity index 100%
rename from internal/fetch/testdata/modcache/github.com/jackc/pgio/@v/v1.0.0.info
rename to internal/fetch/testdata/modcache/cache/download/github.com/jackc/pgio/@v/v1.0.0.info
diff --git a/internal/fetch/testdata/modcache/github.com/jackc/pgio/@v/v1.0.0.mod b/internal/fetch/testdata/modcache/cache/download/github.com/jackc/pgio/@v/v1.0.0.mod
similarity index 100%
rename from internal/fetch/testdata/modcache/github.com/jackc/pgio/@v/v1.0.0.mod
rename to internal/fetch/testdata/modcache/cache/download/github.com/jackc/pgio/@v/v1.0.0.mod
diff --git a/internal/fetch/testdata/modcache/github.com/jackc/pgio/@v/v1.0.0.zip b/internal/fetch/testdata/modcache/cache/download/github.com/jackc/pgio/@v/v1.0.0.zip
similarity index 100%
rename from internal/fetch/testdata/modcache/github.com/jackc/pgio/@v/v1.0.0.zip
rename to internal/fetch/testdata/modcache/cache/download/github.com/jackc/pgio/@v/v1.0.0.zip
Binary files differ
diff --git a/internal/fetch/testdata/modcache/modcache.com/@v/README b/internal/fetch/testdata/modcache/cache/download/modcache.com/@v/README
similarity index 100%
rename from internal/fetch/testdata/modcache/modcache.com/@v/README
rename to internal/fetch/testdata/modcache/cache/download/modcache.com/@v/README
diff --git a/internal/fetch/testdata/modcache/modcache.com/@v/v1.0.0.info b/internal/fetch/testdata/modcache/cache/download/modcache.com/@v/v1.0.0.info
similarity index 100%
rename from internal/fetch/testdata/modcache/modcache.com/@v/v1.0.0.info
rename to internal/fetch/testdata/modcache/cache/download/modcache.com/@v/v1.0.0.info
diff --git a/internal/fetch/testdata/modcache/modcache.com/@v/v1.0.0.mod b/internal/fetch/testdata/modcache/cache/download/modcache.com/@v/v1.0.0.mod
similarity index 100%
rename from internal/fetch/testdata/modcache/modcache.com/@v/v1.0.0.mod
rename to internal/fetch/testdata/modcache/cache/download/modcache.com/@v/v1.0.0.mod
diff --git a/internal/fetch/testdata/modcache/modcache.com/@v/v1.0.0.zip b/internal/fetch/testdata/modcache/cache/download/modcache.com/@v/v1.0.0.zip
similarity index 100%
rename from internal/fetch/testdata/modcache/modcache.com/@v/v1.0.0.zip
rename to internal/fetch/testdata/modcache/cache/download/modcache.com/@v/v1.0.0.zip
Binary files differ
diff --git a/internal/fetch/testdata/modcache/nozip.com/@v/v1.0.0.info b/internal/fetch/testdata/modcache/cache/download/nozip.com/@v/v1.0.0.info
similarity index 100%
rename from internal/fetch/testdata/modcache/nozip.com/@v/v1.0.0.info
rename to internal/fetch/testdata/modcache/cache/download/nozip.com/@v/v1.0.0.info
diff --git a/internal/fetch/testdata/modcache/nozip.com/@v/v1.0.0.mod b/internal/fetch/testdata/modcache/cache/download/nozip.com/@v/v1.0.0.mod
similarity index 100%
rename from internal/fetch/testdata/modcache/nozip.com/@v/v1.0.0.mod
rename to internal/fetch/testdata/modcache/cache/download/nozip.com/@v/v1.0.0.mod
diff --git a/internal/fetch/testdata/modcache/modcache.com@v1.0.0/a.go b/internal/fetch/testdata/modcache/modcache.com@v1.0.0/a.go
new file mode 100644
index 0000000..86f254d
--- /dev/null
+++ b/internal/fetch/testdata/modcache/modcache.com@v1.0.0/a.go
@@ -0,0 +1,6 @@
+// Copyright 2021 The Go Authors. All rights reserved.
+
+package p
+
+// V is a variable.
+var V = 1