Skip to content

Commit bdf78da

Browse files
vanadium23claude
andcommitted
test(metadata): add description field validation for EPUB
Added expected description with typographic quotes (U+201C, U+201D) and apostrophe (U+2019) to match actual metadata extracted from the EPUB file. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 8ef0541 commit bdf78da

1 file changed

Lines changed: 13 additions & 6 deletions

File tree

pkg/metadata/metadata_test.go

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ func getProjectRoot() string {
1515
return filepath.Join(filepath.Dir(b), "..", "..")
1616
}
1717

18+
// epubDescription contains typographic quotes (U+201C, U+201D) and apostrophe (U+2019)
19+
const epubDescription = "(From Wikipedia): Crime and Punishment (Russian: Преступл\u00e9ние и наказ\u00e1ние, Prestupleniye i nakazaniye) is a novel by the Russian author Fyodor Dostoyevsky. It was first published in the literary journal The Russian Messenger in twelve monthly installments during 1866. It was later published in a single volume. It is the second of Dostoyevsky\u2019s full-length novels following his return from ten years of exile in Siberia. Crime and Punishment is the first great novel of his \u201cmature\u201d period of writing. Crime and Punishment focuses on the mental anguish and moral dilemmas of Rodion Raskolnikov, an impoverished ex-student in St. Petersburg who formulates and executes a plan to kill an unscrupulous pawnbroker for her cash. Raskolnikov argues that with the pawnbroker\u2019s money he can perform good deeds to counterbalance the crime, while ridding the world of a worthless vermin. He also commits this murder to test his own hypothesis that some people are naturally capable of such things, and even have the right to do them. Several times throughout the novel, Raskolnikov justifies his actions by comparing himself with Napoleon Bonaparte, believing that murder is permissible in pursuit of a higher purpose."
20+
1821
func TestExtractBookMetadata(t *testing.T) {
1922
projectRoot := getProjectRoot()
2023
booksPath := filepath.Join(projectRoot, "test", "test_data", "books")
@@ -37,12 +40,13 @@ func TestExtractBookMetadata(t *testing.T) {
3740
name: "EPUB",
3841
fileName: "CrimePunishment-EPUB2.epub",
3942
want: metadata.Metadata{
40-
Title: "Crime and Punishment",
41-
Author: "Fyodor Dostoevsky",
42-
Language: "en-us",
43-
Publisher: "BB eBooks Co., Ltd.",
44-
Date: "2016-01-03",
45-
Format: "epub",
43+
Title: "Crime and Punishment",
44+
Author: "Fyodor Dostoevsky",
45+
Language: "en-us",
46+
Publisher: "BB eBooks Co., Ltd.",
47+
Date: "2016-01-03",
48+
Format: "epub",
49+
Description: epubDescription,
4650
},
4751
},
4852
{
@@ -69,6 +73,9 @@ func TestExtractBookMetadata(t *testing.T) {
6973
require.Equal(t, tt.want.Title, got.Title)
7074
require.Equal(t, tt.want.Author, got.Author)
7175
require.Equal(t, tt.want.Format, got.Format)
76+
if tt.want.Description != "" {
77+
require.Equal(t, tt.want.Description, got.Description)
78+
}
7279
if tt.want.Language != "" {
7380
require.Equal(t, tt.want.Language, got.Language)
7481
}

0 commit comments

Comments
 (0)