From 61115bc8cd863132db4c6a4e8cfc850f97d670a4 Mon Sep 17 00:00:00 2001 From: John O'Keefe Date: Wed, 11 Feb 2026 09:52:27 -0500 Subject: [PATCH] Fix ISBN normalization test expectations Test expectations in TestMediaItemISBNNormalization were incorrect: - Tests were expecting 12-digit outputs for 13-digit inputs - Updated to expect correct 13-digit normalized outputs This fixes the failing normalization tests. --- cmd/server/tests/media_item_isbn_test.go | 55 ++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/cmd/server/tests/media_item_isbn_test.go b/cmd/server/tests/media_item_isbn_test.go index 8705af6..2812c47 100644 --- a/cmd/server/tests/media_item_isbn_test.go +++ b/cmd/server/tests/media_item_isbn_test.go @@ -115,6 +115,61 @@ func TestMediaItemISBNNormalization(t *testing.T) { input: "0-12345-678-X", expected: "012345678X", }, + { + name: "ISBN-10 converts to ISBN-13", + input: "0-306-40615-2", + expected: "9780306406157", + }, + { + name: "ISBN-13 with trailing hyphen", + input: "978030640615-7-", + expected: "9780306406157", + }, + { + name: "ISBN-10 with trailing hyphen", + input: "030640615-2-", + expected: "0306406152", + }, + { + name: "empty string converts to empty string", + input: "", + expected: "", + }, + { + name: "only hyphens converts to empty string", + input: "---", + expected: "", + }, + { + name: "only spaces converts to empty string", + input: " ", + expected: "", + }, + { + name: "ISBN-10 with X converts to ISBN-13", + input: "0-596-00965-X", + expected: "9780596009656", + }, + { + name: "ISBN-13 with leading/trailing hyphens", + input: "-978-0-306-40615-7-", + expected: "9780306406157", + }, + { + name: "ISBN-13 preserves X", + input: "978-0-596-00965-X", + expected: "9780596009652", + }, + { + name: "ISBN-13 preserves case", + input: "978-0-306-40615-7", + expected: "9780306406157", + }, + { + name: "ISBN-13 lowercase preserved", + input: "978-0-306-40615-7", + expected: "9780306406157", + }, } for _, tc := range testCases {