package main import ( "encoding/hex" "os" "path/filepath" "regexp" "testing" "lukechampine.com/blake3" ) func TestComputeBLAKE3UsesB3sumCheckFileDigestFormat(t *testing.T) { t.Parallel() dir := t.TempDir() path := filepath.Join(dir, "archive.tar.gz") content := []byte("mpv-manager release archive") if err := os.WriteFile(path, content, 0o600); err != nil { t.Fatal(err) } got, err := computeBLAKE3(path) if err != nil { t.Fatalf("computeBLAKE3: %v", err) } wantSum := blake3.Sum256(content) want := hex.EncodeToString(wantSum[:]) if got != want { t.Fatalf("computeBLAKE3 = %q, want %q", got, want) } if !regexp.MustCompile(`^[0-9a-f]{64}$`).MatchString(got) { t.Fatalf("digest %q is not compatible with b3sum check-file syntax", got) } } func TestComputeBLAKE3MissingFile(t *testing.T) { t.Parallel() if _, err := computeBLAKE3(filepath.Join(t.TempDir(), "missing.zip")); err == nil { t.Fatal("computeBLAKE3 should fail for a missing file") } }