internal/frontend: fix TestFetchPathAlreadyExists/491
Fixes TestFetchPathAlreadyExists/491, which was broken in CL 242458.
Change-Id: I9877a971f24874f3772dc057c978bea6d9d8bde8
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/242640
Reviewed-by: Jonathan Amsterdam <jba@google.com>
diff --git a/internal/frontend/fetch_test.go b/internal/frontend/fetch_test.go
index a59230c..103287d 100644
--- a/internal/frontend/fetch_test.go
+++ b/internal/frontend/fetch_test.go
@@ -143,12 +143,14 @@
}
func TestFetchPathAlreadyExists(t *testing.T) {
- for _, status := range []int{
- http.StatusOK,
- http.StatusNotFound,
- derrors.ToHTTPStatus(derrors.AlternativeModule),
+ for _, test := range []struct {
+ status, want int
+ }{
+ {http.StatusOK, http.StatusOK},
+ {http.StatusNotFound, http.StatusNotFound},
+ {derrors.ToHTTPStatus(derrors.AlternativeModule), http.StatusSeeOther},
} {
- t.Run(strconv.Itoa(status), func(t *testing.T) {
+ t.Run(strconv.Itoa(test.status), func(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), testFetchTimeout)
defer cancel()
ctx = experiment.NewContext(ctx,
@@ -161,7 +163,7 @@
ModulePath: sample.ModulePath,
RequestedVersion: sample.VersionString,
ResolvedVersion: sample.VersionString,
- Status: status,
+ Status: test.status,
}); err != nil {
t.Fatal(err)
}
@@ -169,8 +171,8 @@
s, _, teardown := newTestServer(t, testModulesForProxy)
defer teardown()
got, _ := s.fetchAndPoll(ctx, sample.ModulePath, sample.PackagePath, sample.VersionString)
- if got != status {
- t.Fatalf("fetchAndPoll for status %d: %d; want = %d)", status, got, status)
+ if got != test.want {
+ t.Fatalf("fetchAndPoll for status %d: %d; want = %d)", test.status, got, test.want)
}
})
}