-
-
Notifications
You must be signed in to change notification settings - Fork 62
Library::removeBookById() updates the reader list and the search DB #485
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The `XmlLibraryTest.removeBookByIdDropsTheReader` unit-test fails, demonstrating a bug in `kiwix::Library::removeBookById()`.
This fix makes the `XmlLibraryTest.removeBookByIdDropsTheReader` unit-test pass.
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 changes how the `XmlLibraryTest.removeBookByIdUpdatesTheSearchDB` unit-test fails.
This fix makes the `XmlLibraryTest.removeBookByIdUpdatesTheSearchDB` unit-test pass.
Codecov Report
@@ Coverage Diff @@
## master #485 +/- ##
==========================================
+ Coverage 63.07% 63.14% +0.07%
==========================================
Files 50 50
Lines 3504 3506 +2
Branches 1770 1771 +1
==========================================
+ Hits 2210 2214 +4
+ Misses 1292 1290 -2
Partials 2 2
Continue to review full report at Codecov.
|
@@ -331,7 +331,7 @@ Library::BookIdCollection Library::filter(const Filter& filter) | |||
{ | |||
BookIdCollection result; | |||
for(auto id : getBooksByTitleOrDescription(filter)) { | |||
if(filter.acceptByNonQueryCriteria(m_books[id])) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This bug was introduced in #460 because Library::filter()
is not declared const
.
Fixes #478
I added a new test-suite
XmlLibraryTest
so that I could make use of theLibrary::getReaderById()
method (a library constructed from an OPDS stream doesn't contain local books).