Skip to content
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

Deduplication of server search results unittests #780

Merged
merged 10 commits into from
Jun 10, 2022

Conversation

veloman-yunkan
Copy link
Collaborator

A follow-up of #731 (comment)

@codecov
Copy link

codecov bot commented Jun 4, 2022

Codecov Report

Merging #780 (3bbbd1b) into master (3bbbd1b) will not change coverage.
The diff coverage is n/a.

❗ Current head 3bbbd1b differs from pull request most recent head baa97ca. Consider uploading reports for the commit baa97ca to get more accurate results

@@           Coverage Diff           @@
##           master     #780   +/-   ##
=======================================
  Coverage   63.66%   63.66%           
=======================================
  Files          59       59           
  Lines        4073     4073           
  Branches     2218     2218           
=======================================
  Hits         2593     2593           
  Misses       1478     1478           
  Partials        2        2           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3bbbd1b...baa97ca. Read the comment docs.

@kelson42 kelson42 added this to the 10.3.0 milestone Jun 4, 2022
Copy link
Member

@mgautierfr mgautierfr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two small comments to discuss/fix.
But we are mostly good.

test/server_search.cpp Show resolved Hide resolved
std::string s;
for ( const auto& r : results ) {
s += "\n <item>\n";
s += maskSnippetsInXmlSearchResults(r.getXml());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we could generate xml (and html) without snippets instead of generated a full xml and mask the snippet.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would mean having a special mode for the /search endpoint (e.g. /search?snippets=no), however I don't think that adding it for testing alone makes sense. Besides, we ignore snippets only at this point. Later snippets are validated too.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was speaking about the generation of the expected result. We would still have to mask the snippet in the actual results of the tested server.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense. But not to an extent to pursue it if this is going to be the only thing to fix about this PR.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Frankly I would rather change TestData::expectedXmlResultsString() to return the real expected response body and perform the masking out of snippets at the check site. That will eliminate some confusion implanted in the current code.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But not to an extent to pursue it if this is going to be the only thing to fix about this PR.

Agree with that.

Frankly I would rather change TestData::expectedXmlResultsString() to return the real expected response body and perform the masking out of snippets at the check site.

This is the other way around. Feel free to do it (but not in this PR, I approve and merge it)

Unit-tests of search results in XML format should work the same way with
a server that would inject a taskbar into HTML responses. This small
change actually validates that taskbar injection is disabled for XML
responses.
Now ServerTest provides an optional taskbarless kiwix::Server.
Now that ServerTest.searchResults is in a separate cpp file, there are
no reasons for hiding its test data definition inside the unit test
function.

The diff is much-much simpler if whitespace changes are ignored.
Included the word "Html" in the names of those functions and variables
which will get Xml siblings soon.
@mgautierfr mgautierfr force-pushed the deduping_searchResults_unittests branch from 4f11dbe to baa97ca Compare June 10, 2022 13:34
@mgautierfr mgautierfr self-requested a review June 10, 2022 13:34
@mgautierfr mgautierfr merged commit 83a9e54 into master Jun 10, 2022
@mgautierfr mgautierfr deleted the deduping_searchResults_unittests branch June 10, 2022 13:47
@kelson42 kelson42 modified the milestones: 11.1.0, 11.0.0 Jun 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants