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

Retail search samples with tests (new) #1628

Merged

Conversation

vasilypascal
Copy link
Contributor

  • Added retails search samples
  • Added tests
  • Created Runner project, which executes the sample by it's name with the help of ExampleAttributeHelper class

@product-auto-label product-auto-label bot added the samples Issues that are directly related to samples. label Feb 14, 2022
@snippet-bot
Copy link

snippet-bot bot commented Feb 14, 2022

Here is the summary of changes.

You are about to add 6 region tags.

This comment is generated by snippet-bot.
If you find problems with this result, please file an issue at:
https://github.com/googleapis/repo-automation-bots/issues.
To update this comment, add snippet-bot:force-run label or use the checkbox below:

  • Refresh this comment

@amanda-tarafa amanda-tarafa added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Feb 14, 2022
@kokoro-team kokoro-team removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Feb 14, 2022
@t-karasova t-karasova mentioned this pull request Feb 14, 2022
Copy link
Member

@amanda-tarafa amanda-tarafa left a comment

Choose a reason for hiding this comment

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

This looks really good.

I have some minor requests.
And also, about the pagination sample, something needs to be done there so we can test all the code. Either split the sample in three different samples or create three different methods, one for each pagination "mode" you want to show. If you think this is going to take some time, I'm happy if you remove that sample and its test from this PR, and add it in a following PR.

Comment on lines 29 to 30
var firstPage = searchResultPages.ToArray()[0];
var thirdPage = searchResultPages.ToArray()[2];
Copy link
Member

Choose a reason for hiding this comment

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

Doing this twice means that we fetch everything from the backend twice, i.e. all pages. In this case it is better to do something like:

Suggested change
var firstPage = searchResultPages.ToArray()[0];
var thirdPage = searchResultPages.ToArray()[2];
var topPages = searchResultPages.Take(3).ToList();
var firstPage = topPages[0];
var thirdPage = topPages[2];

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agree. Will improve that

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Resolved.

}
}

// Paste call with next page token here:
Copy link
Member

Choose a reason for hiding this comment

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

We cannot tests all of this code because it is commented.
Also we don't use commented code in documentation samples.

I think it's best if you have a sample for each of these.

Copy link
Contributor Author

@vasilypascal vasilypascal Feb 14, 2022

Choose a reason for hiding this comment

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

Removed the SearchWithPagination Sample for now by the agreement with @tetiana-karasova

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Resolved.

@vasilypascal
Copy link
Contributor Author

vasilypascal commented Feb 14, 2022

@amanda-tarafa
Fixed tests, added commented explanation for Intervals and removed SearchWithPagination class for now.

@kweinmeister kweinmeister added kokoro:force-run Add this label to force Kokoro to re-run the tests. owlbot:run Add this label to trigger the Owlbot post processor. labels Feb 14, 2022
@kokoro-team kokoro-team removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Feb 14, 2022
@amanda-tarafa amanda-tarafa removed the owlbot:run Add this label to trigger the Owlbot post processor. label Feb 15, 2022
Copy link
Member

@amanda-tarafa amanda-tarafa left a comment

Choose a reason for hiding this comment

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

LGTM!

Thanks!

@amanda-tarafa
Copy link
Member

Failures in CI are unrelated and being tracked in #1623.

@amanda-tarafa amanda-tarafa merged commit d8ba0d2 into GoogleCloudPlatform:main Feb 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
samples Issues that are directly related to samples.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants