Enhanced test library.xml with an entry not backed by a ZIM file

The test data was modified so that support for catalog only mode
of kiwix-serve can be properly tested.

The effect of this change in the test data on the library_server unit
test demonstrates that although the new entry does not appear in the
catalog (for example, no catalog_v2_entries* test cases were affected)
the category and language of this ghost entry slipped into the
observable output.
This commit is contained in:
Veloman Yunkan
2025-09-04 17:14:44 +04:00
parent 95fc478e37
commit 8a3c4c92e0
3 changed files with 41 additions and 0 deletions

View File

@@ -51,4 +51,21 @@
size="556" size="556"
favicon="faviconMimeType_attribute_is_absent" favicon="faviconMimeType_attribute_is_absent"
></book> ></book>
<book
id="inaccessiblezim"
path="./nosuchzimfile.zim"
url="https://github.com/kiwix/libkiwix/raw/master/test/data/nosuchzimfile.zim"
title="Catalog of all catalogs"
description="Testing that running kiwix-serve without access to ZIM files doesn't lead to a catastrophe"
language="cat"
creator="Catherine of Catalonia"
publisher="Caterpillar"
date="2025-09-04"
name="catalog_of_all_catalogs"
tags="unittest;_category:cats"
articleCount="12107"
mediaCount="8"
size="20250904"
favicon="Catania Cathedral"
></book>
</library> </library>

View File

@@ -560,6 +560,15 @@ TEST_F(LibraryServerTest, catalog_v2_categories)
<title>List of categories</title> <title>List of categories</title>
<updated>YYYY-MM-DDThh:mm:ssZ</updated> <updated>YYYY-MM-DDThh:mm:ssZ</updated>
<entry>
<title>cats</title>
<link rel="subsection"
href="/ROOT%23%3F/catalog/v2/entries?category=cats"
type="application/atom+xml;profile=opds-catalog;kind=acquisition"/>
<updated>YYYY-MM-DDThh:mm:ssZ</updated>
<id>12345678-90ab-cdef-1234-567890abcdef</id>
<content type="text">All entries with category of 'cats'.</content>
</entry>
<entry> <entry>
<title>jazz</title> <title>jazz</title>
<link rel="subsection" <link rel="subsection"
@@ -602,6 +611,16 @@ TEST_F(LibraryServerTest, catalog_v2_languages)
<title>List of languages</title> <title>List of languages</title>
<updated>YYYY-MM-DDThh:mm:ssZ</updated> <updated>YYYY-MM-DDThh:mm:ssZ</updated>
<entry>
<title>català</title>
<dc:language>cat</dc:language>
<thr:count>1</thr:count>
<link rel="subsection"
href="/ROOT%23%3F/catalog/v2/entries?lang=cat"
type="application/atom+xml;profile=opds-catalog;kind=acquisition"/>
<updated>YYYY-MM-DDThh:mm:ssZ</updated>
<id>12345678-90ab-cdef-1234-567890abcdef</id>
</entry>
<entry> <entry>
<title>English</title> <title>English</title>
<dc:language>eng</dc:language> <dc:language>eng</dc:language>
@@ -1332,6 +1351,7 @@ TEST_F(LibraryServerTest, no_name_mapper_catalog_v2_individual_entry_access)
" <div class=\"kiwixNav__select\">\n" \ " <div class=\"kiwixNav__select\">\n" \
" <select name=\"lang\" id=\"languageFilter\" class='kiwixNav__kiwixFilter filter' form=\"kiwixSearchForm\">\n" \ " <select name=\"lang\" id=\"languageFilter\" class='kiwixNav__kiwixFilter filter' form=\"kiwixSearchForm\">\n" \
" <option value=\"\" selected>All languages</option>\n" \ " <option value=\"\" selected>All languages</option>\n" \
" <option value=\"cat\">català</option>\n" \
" <option value=\"eng\"" SELECTED_ENG ">English</option>\n" \ " <option value=\"eng\"" SELECTED_ENG ">English</option>\n" \
" <option value=\"fra\">français</option>\n" \ " <option value=\"fra\">français</option>\n" \
" <option value=\"rus\">русский</option>\n" \ " <option value=\"rus\">русский</option>\n" \
@@ -1340,6 +1360,7 @@ TEST_F(LibraryServerTest, no_name_mapper_catalog_v2_individual_entry_access)
" <div class=\"kiwixNav__select\">\n" \ " <div class=\"kiwixNav__select\">\n" \
" <select name=\"category\" id=\"categoryFilter\" class='kiwixNav__kiwixFilter filter' form=\"kiwixSearchForm\">\n" \ " <select name=\"category\" id=\"categoryFilter\" class='kiwixNav__kiwixFilter filter' form=\"kiwixSearchForm\">\n" \
" <option value=\"\">All categories</option>\n" \ " <option value=\"\">All categories</option>\n" \
" <option value=\"cats\">Cats</option>\n" \
" <option value=\"jazz\">Jazz</option>\n" \ " <option value=\"jazz\">Jazz</option>\n" \
" <option value=\"wikipedia\">Wikipedia</option>\n" \ " <option value=\"wikipedia\">Wikipedia</option>\n" \
" </select>\n" \ " </select>\n" \

View File

@@ -88,6 +88,7 @@ TEST(Manager, reload)
manager.reload({ "./test/library.xml" }); manager.reload({ "./test/library.xml" });
EXPECT_EQ(lib->getBooksIds(), (kiwix::Library::BookIdCollection{ EXPECT_EQ(lib->getBooksIds(), (kiwix::Library::BookIdCollection{
"charlesray", "charlesray",
"inaccessiblezim",
"raycharles", "raycharles",
"raycharles_uncategorized" "raycharles_uncategorized"
})); }));
@@ -95,12 +96,14 @@ TEST(Manager, reload)
lib->removeBookById("raycharles"); lib->removeBookById("raycharles");
EXPECT_EQ(lib->getBooksIds(), (kiwix::Library::BookIdCollection{ EXPECT_EQ(lib->getBooksIds(), (kiwix::Library::BookIdCollection{
"charlesray", "charlesray",
"inaccessiblezim",
"raycharles_uncategorized" "raycharles_uncategorized"
})); }));
manager.reload({ "./test/library.xml" }); manager.reload({ "./test/library.xml" });
EXPECT_EQ(lib->getBooksIds(), kiwix::Library::BookIdCollection({ EXPECT_EQ(lib->getBooksIds(), kiwix::Library::BookIdCollection({
"charlesray", "charlesray",
"inaccessiblezim",
"raycharles", "raycharles",
"raycharles_uncategorized" "raycharles_uncategorized"
})); }));