MCPcopy Index your code
hub / github.com/codehamr/codehamr / newFakeRelease

Function newFakeRelease

internal/update/update_test.go:27–43  ·  view source on GitHub ↗
(t *testing.T, asset string, body []byte, declared string)

Source from the content-addressed store, hash-verified

25}
26
27func 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.

Calls 1

WriteMethod · 0.80

Tested by

no test coverage detected