From 6d44ae884c0724c37167bb20f34cac6b813a8f42 Mon Sep 17 00:00:00 2001 From: John O'Keefe Date: Mon, 8 Jun 2026 19:45:12 -0400 Subject: [PATCH] chore(tests): remove debug tests that depend on local file paths Remove TestConvertHessBook and TestDebugHess (both referenced a non-existent Hess EPUB at an absolute local path) and TestConvertCPByTextSearch (referenced a Crime and Punishment EPUB in the local uploads directory). These were development-time debug tests that only worked on the author's machine. All CFI/KEPUB conversion behavior is already covered by the proper fixture-based tests (TestKEPUBRoundTrip, TestKEPUBConvertKEPUBToStandard, TestKEPUBConvertWithEmElements, etc.) which use createTestEPUB and createTestKEPUB helpers. --- internal/sync/cfi_converter_test.go | 45 ----------------------------- internal/sync/cfi_debug_test.go | 37 ------------------------ 2 files changed, 82 deletions(-) delete mode 100644 internal/sync/cfi_debug_test.go diff --git a/internal/sync/cfi_converter_test.go b/internal/sync/cfi_converter_test.go index b5c9e6d..f8cfdd4 100644 --- a/internal/sync/cfi_converter_test.go +++ b/internal/sync/cfi_converter_test.go @@ -162,51 +162,6 @@ func TestConvertCrimeAndPunishmentFragmentID(t *testing.T) { } } -func TestConvertHessBook(t *testing.T) { - epubPath := "/home/nymusicman/Code/bookhoard/William L Hess/Crushing the Great Serpent_ Did God (42)/Crushing the Great Serpent_ Did - William L Hess.epub" - c := NewCFIConverter(epubPath) - - xp := "/body/DocFragment[5]/body/div[3]/p[28]/text().500" - result, err := c.ConvertCREToStandard(xp, 0.08, "") - if err != nil { - t.Fatalf("ConvertCREToStandard error: %v", err) - } - t.Logf("Input: %s", xp) - t.Logf("EPUBCFI: %s", result.EPUBCFI) - t.Logf("Href: %s", result.Href) - t.Logf("Precision: %s", result.Precision) - t.Logf("Percentage: %.4f", result.Percentage) - - if result.Precision == "percentage" { - t.Error("expected better than percentage precision") - } -} - -func TestConvertCPByTextSearch(t *testing.T) { - epubPath := "/home/nymusicman/Code/bookhoard/uploads/Ebooks/Fyodor Dostoyevsky/Crime and Punishment (103)/Crime and Punishment - Fyodor Dostoyevsky.epub" - c := NewCFIConverter(epubPath) - - xp := "/body/DocFragment[6]/body/div/p[47]/text().1" - contextText := "Raskolnikov was not used to crowds, and, as we said before, he avoided society of every sort, more especially of l" - result, err := c.ConvertCREToStandard(xp, 0.0579, contextText) - if err != nil { - t.Fatalf("ConvertCREToStandard error: %v", err) - } - t.Logf("Input: %s", xp) - t.Logf("ContextText: %s", contextText) - t.Logf("EPUBCFI: %s", result.EPUBCFI) - t.Logf("Href: %s", result.Href) - t.Logf("Precision: %s", result.Precision) - t.Logf("Percentage: %.4f", result.Percentage) - - if result.Precision != "exact" { - t.Errorf("expected exact precision, got %s", result.Precision) - } - if result.EPUBCFI == "" { - t.Error("expected non-empty EPUBCFI") - } -} - func TestParseEPUBCFI(t *testing.T) { tests := []struct { input string diff --git a/internal/sync/cfi_debug_test.go b/internal/sync/cfi_debug_test.go deleted file mode 100644 index eef798f..0000000 --- a/internal/sync/cfi_debug_test.go +++ /dev/null @@ -1,37 +0,0 @@ -package sync - -import "testing" - -func TestDebugHess(t *testing.T) { - epubPath := "/home/nymusicman/Code/bookhoard/William L Hess/Crushing the Great Serpent_ Did God (42)/Crushing the Great Serpent_ Did - William L Hess.epub" - c := NewCFIConverter(epubPath) - - xp, err := ParseCREXPointer("/body/DocFragment[5]/body/div[3]/p[28]/text().500") - if err != nil { - t.Fatal(err) - } - t.Logf("FragmentIndex: %d, CharOffset: %d", xp.FragmentIndex, xp.CharOffset) - - doc, href, err := c.getContentDoc(xp.FragmentIndex) - if err != nil { - t.Fatalf("getContentDoc error: %v", err) - } - t.Logf("href: %s", href) - - body := findBody(doc) - if body == nil { - t.Fatal("no body") - } - - totalChars := countTextChars(body) - t.Logf("total chars in doc: %d", totalChars) - - target, foundOffset := findNodeAtCharOffset(body, 500) - if target == nil { - t.Fatal("target is nil") - } - t.Logf("foundOffset: %d target: <%s>", foundOffset, target.Data) - - cfi, err := buildCFI(5, target, 0) - t.Logf("cfi: %q err: %v", cfi, err) -}