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

Test coverage for the search scheduler #5

Open
olivierobert opened this issue Jan 21, 2022 · 3 comments
Open

Test coverage for the search scheduler #5

olivierobert opened this issue Jan 21, 2022 · 3 comments

Comments

@olivierobert
Copy link

Overall, there are not many unit tests for the codebase but one of the packages that are tested is scheduler. However, why not test the public methods such as ScheduleKeywordParser or ScrapResult as these are exposed to the rest of the application?

In addition, this would also might put in question if many of the other methods should not be exported e.g., PrintSearchResult, GetSearchResult, etc. should probably be printSearchResult, getSearchResult, etc.

@rashikzaman
Copy link
Owner

rashikzaman commented Jan 22, 2022

A lot of business logic in the code-base are directly db related. This kind of test involves mocking db client. Sadly, I still need to learn mocking db layer. However, since I used interfaces across the layers, mocking should be done pretty easily.

Other than the tests in scheduler packages, I've done some end-to-end test in http package. But writing end-to-end to cover all edge cases is pretty lengthy process.

ScheduleKeywordParser or ScheduleKeywordParser methods directly depends upon querying google search result page due to their dependency on getSearchResult method. One way to mock test this were to use mock http client and use dependency injection. I need to study how to do these properly.

@rashikzaman
Copy link
Owner

Methods in the scheduler packages are properly encapsulated now. This is the pull request

@olivierobert
Copy link
Author

Thank you for your comments and efforts 👍

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

No branches or pull requests

2 participants