(t *testing.T, latestVersion string, existingTags map[string]bool)
| 411 | } |
| 412 | |
| 413 | func newCompileUpdateCheckTestServer(t *testing.T, latestVersion string, existingTags map[string]bool) *httptest.Server { |
| 414 | t.Helper() |
| 415 | |
| 416 | mux := http.NewServeMux() |
| 417 | mux.HandleFunc("/releases/latest", func(w http.ResponseWriter, r *http.Request) { |
| 418 | http.Redirect(w, r, "/github/gh-aw/releases/tag/"+latestVersion, http.StatusFound) |
| 419 | }) |
| 420 | mux.HandleFunc("/github/gh-aw/releases/tag/"+latestVersion, func(w http.ResponseWriter, r *http.Request) { |
| 421 | w.WriteHeader(http.StatusOK) |
| 422 | _, _ = w.Write([]byte("release page")) |
| 423 | }) |
| 424 | mux.HandleFunc("/raw/", func(w http.ResponseWriter, r *http.Request) { |
| 425 | tag := r.URL.Path[len("/raw/"):] |
| 426 | tag = tag[:len(tag)-len("/go.mod")] |
| 427 | if existingTags[tag] { |
| 428 | w.WriteHeader(http.StatusOK) |
| 429 | _, _ = w.Write([]byte("module github.com/github/gh-aw\n")) |
| 430 | return |
| 431 | } |
| 432 | http.NotFound(w, r) |
| 433 | }) |
| 434 | |
| 435 | return httptest.NewServer(mux) |
| 436 | } |
| 437 | |
| 438 | func newCompileUpdateCheckMethodServer(t *testing.T, latestVersion string, existingTags map[string]bool) (*httptest.Server, map[string][]string) { |
| 439 | t.Helper() |
no test coverage detected