MCPcopy Create free account
hub / github.com/driangle/taskmd / TestHashLocalFile

Function TestHashLocalFile

apps/cli/internal/sync/engine_test.go:517–545  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

515}
516
517func TestHashLocalFile(t *testing.T) {
518 dir := t.TempDir()
519 path := filepath.Join(dir, "test.md")
520 writeFile(t, path, "hello world")
521
522 h1, err := HashLocalFile(path)
523 if err != nil {
524 t.Fatalf("unexpected error: %v", err)
525 }
526
527 h2, err := HashLocalFile(path)
528 if err != nil {
529 t.Fatalf("unexpected error: %v", err)
530 }
531
532 if h1 != h2 {
533 t.Error("hash not deterministic")
534 }
535
536 // Different content → different hash
537 writeFile(t, path, "different content")
538 h3, err := HashLocalFile(path)
539 if err != nil {
540 t.Fatalf("unexpected error: %v", err)
541 }
542 if h1 == h3 {
543 t.Error("expected different hash for different content")
544 }
545}
546
547func TestHashLocalFile_NonexistentFile(t *testing.T) {
548 _, err := HashLocalFile("/nonexistent/path.md")

Callers

nothing calls this directly

Calls 3

HashLocalFileFunction · 0.85
ErrorMethod · 0.80
writeFileFunction · 0.70

Tested by

no test coverage detected