(t *testing.T)
| 316 | } |
| 317 | |
| 318 | func TestVerifyChecksum(t *testing.T) { |
| 319 | // Create a temp file with known content |
| 320 | dir := t.TempDir() |
| 321 | filePath := filepath.Join(dir, "binary") |
| 322 | content := []byte("test binary content") |
| 323 | os.WriteFile(filePath, content, 0o644) |
| 324 | |
| 325 | // Calculate expected hash |
| 326 | h := sha256.Sum256(content) |
| 327 | expectedHash := hex.EncodeToString(h[:]) |
| 328 | |
| 329 | // Serve checksum |
| 330 | srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 331 | fmt.Fprintf(w, "%s binary\n", expectedHash) |
| 332 | })) |
| 333 | defer srv.Close() |
| 334 | |
| 335 | if err := verifyChecksum(filePath, srv.URL); err != nil { |
| 336 | t.Errorf("expected checksum verification to pass: %v", err) |
| 337 | } |
| 338 | } |
| 339 | |
| 340 | func TestVerifyChecksum_Mismatch(t *testing.T) { |
| 341 | dir := t.TempDir() |
nothing calls this directly
no test coverage detected