(t *testing.T, asset string, body []byte, declared string)
| 25 | } |
| 26 | |
| 27 | func newFakeRelease(t *testing.T, asset string, body []byte, declared string) *fakeRelease { |
| 28 | t.Helper() |
| 29 | r := &fakeRelease{binary: body, asset: asset} |
| 30 | r.manifest = fmt.Sprintf("%s %s\n", declared, asset) |
| 31 | r.srv = httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { |
| 32 | switch req.URL.Path { |
| 33 | case "/" + asset: |
| 34 | _, _ = w.Write(body) |
| 35 | case "/codehamr_checksums.txt": |
| 36 | _, _ = w.Write([]byte(r.manifest)) |
| 37 | default: |
| 38 | http.NotFound(w, req) |
| 39 | } |
| 40 | })) |
| 41 | t.Cleanup(r.srv.Close) |
| 42 | return r |
| 43 | } |
| 44 | |
| 45 | // withReleaseURLs swaps checksumsURL and releaseBase for one test; safe only |
| 46 | // because these tests don't run in parallel. |
no test coverage detected