From 0f79d9d242e3db9600625853f1c5c13a5fdd65ae Mon Sep 17 00:00:00 2001 From: Veloman Yunkan Date: Wed, 26 Apr 2023 12:40:01 +0400 Subject: [PATCH] Another test for complex constraints on metadata --- test/metadata-test.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/test/metadata-test.cpp b/test/metadata-test.cpp index 7a50df58..fe5110d7 100644 --- a/test/metadata-test.cpp +++ b/test/metadata-test.cpp @@ -195,3 +195,34 @@ TEST(Metadata, mandatoryMetadataAndSimpleChecksAreRunUnconditionally) }) ); } + +TEST(Metadata, complexChecksAreRunOnlyIfMandatoryMetadataRequirementsAreMet) +{ + zim::Metadata m; + + m.set("Description", "Blablabla"); + m.set("LongDescription", "Blabla"); + m.set("Date", "2020-20-20"); + m.set("Creator", "TED"); + m.set("Name", "TED_bodylanguage"); + //m.set("Title", ""); + m.set("Publisher", "Kiwix"); + m.set("Language", "bod,yla,ngu,age"); + m.set("Illustration_48x48@1", fakePNG()); + + ASSERT_FALSE(m.valid()); + ASSERT_EQ(m.check(), + zim::Metadata::Errors({ + "Missing mandatory metadata: Title", + }) + ); + + m.set("Title", "Blabluba"); + + ASSERT_FALSE(m.valid()); + ASSERT_EQ(m.check(), + zim::Metadata::Errors({ + "LongDescription shouldn't be shorter than Description" + }) + ); +}