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

Function TestFetchHashHandlesCorruptManifest

internal/update/update_test.go:276–292  ·  view source on GitHub ↗

TestFetchHashHandlesCorruptManifest: a manifest not in ` ` form must not crash fetchHash; it just yields an empty hash.

(t *testing.T)

Source from the content-addressed store, hash-verified

274// TestFetchHashHandlesCorruptManifest: a manifest not in `<hash> <name>`
275// form must not crash fetchHash; it just yields an empty hash.
276func TestFetchHashHandlesCorruptManifest(t *testing.T) {
277 srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
278 _, _ = w.Write([]byte("not a real manifest\nrandom text\n"))
279 }))
280 t.Cleanup(srv.Close)
281 origCS := checksumsURL
282 checksumsURL = srv.URL + "/codehamr_checksums.txt"
283 t.Cleanup(func() { checksumsURL = origCS })
284
285 got, err := fetchHash(context.Background(), "codehamr-linux-amd64")
286 if err != nil {
287 t.Fatalf("corrupt manifest should not error, got: %v", err)
288 }
289 if got != "" {
290 t.Fatalf("missing entry should yield empty hash, got %q", got)
291 }
292}
293
294// TestCheckHonoursEnvDisableFlag: CODEHAMR_NO_UPDATE_CHECK=1 must short-circuit
295// Check before any HTTP work, sparing CI/offline launches the fetch deadline.

Callers

nothing calls this directly

Calls 2

fetchHashFunction · 0.85
WriteMethod · 0.80

Tested by

no test coverage detected