MCPcopy Create free account
hub / github.com/github/gh-aw / newCompileUpdateCheckTestServer

Function newCompileUpdateCheckTestServer

pkg/cli/compile_update_check_test.go:413–436  ·  view source on GitHub ↗
(t *testing.T, latestVersion string, existingTags map[string]bool)

Source from the content-addressed store, hash-verified

411}
412
413func 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
438func newCompileUpdateCheckMethodServer(t *testing.T, latestVersion string, existingTags map[string]bool) (*httptest.Server, map[string][]string) {
439 t.Helper()

Callers 1

Calls 1

WriteMethod · 0.80

Tested by

no test coverage detected