mirror of https://github.com/kiwix/libkiwix.git
XmlLibraryTest.removeBookByIdUpdatesTheSearchDB
The new unit-test fails with a reason not expected before it was written. The `Library::filter()` operation returns a correct result after the call to `removeBookById()` (this was a surprise!) but it has a side-effect of re-adding an empty book with the id still surviving in the search DB (the emptiness of this re-created book doesn't allow it to pass the other filtering criteria, which explains why the result of `Library::filter()` is correct). Had to add a special check to the new unit-test against that hidden side-effect of `Library::removeBookById()` + `Library::filter()` combination.
This commit is contained in:
parent
24ed96a38c
commit
49940a30d0
|
@ -310,4 +310,22 @@ TEST_F(XmlLibraryTest, removeBookByIdDropsTheReader)
|
|||
EXPECT_THROW(lib.getReaderById("raycharles"), std::out_of_range);
|
||||
};
|
||||
|
||||
TEST_F(XmlLibraryTest, removeBookByIdUpdatesTheSearchDB)
|
||||
{
|
||||
kiwix::Filter f;
|
||||
f.local(true).valid(true).query(R"(title:"ray charles")", false);
|
||||
|
||||
EXPECT_NO_THROW(lib.getBookById("raycharles"));
|
||||
EXPECT_EQ(1U, lib.filter(f).size());
|
||||
|
||||
lib.removeBookById("raycharles");
|
||||
|
||||
EXPECT_THROW(lib.getBookById("raycharles"), std::out_of_range);
|
||||
EXPECT_EQ(0U, lib.filter(f).size());
|
||||
|
||||
// make sure that Library::filter() doesn't add an empty book with
|
||||
// an id surviving in the search DB
|
||||
EXPECT_THROW(lib.getBookById("raycharles"), std::out_of_range);
|
||||
};
|
||||
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue