fake-news-detector / api

API for saving news flagging by the users
https://fake-news-detector-api.herokuapp.com/
8 stars 1 forks source link

#12 Add integration tests to healthcheck endpoint #19

Closed dawsonfi closed 6 years ago

dawsonfi commented 6 years ago

hey @rogeriochaves,

I want to help creating some tests (unit and integration) for the endpoints.

In order to create integration tests, i had to create the lib file, and use the project as a crate in main.rs.

Also, there was a module called lib, witch i had to rename in order to solve an compiler error with the newly created lib.rs. Having not much context, i've renamed it to commons, i think you might have a suggestion for a better name.

If is good for you, i will try to create tests for the other endpoints.

ps.: there was a failing test scrapper::scrapper::tests::it_extracts_text_from_url, so i've changed the assert text in order to fix it. If you could a look at it please, that would be great :)

rogeriochaves commented 6 years ago

Omg that is AWESOME! Thank you

This refactoring is great, it seems that creating a lib is the way to go with rust right, let me know when I can merge this and we can add more tests later. And yes, common is a good name!

Don't mind circleci failing, it is trying to pull an image from heroku which you don't have access, I'll move the docker image to a public dockerhub one to fix this (#20)

It's rare that it_extracts_text_from_url started failing, but maybe the url under test changed indeed, and this test is not using fixtures for now, it's checking the real url, so that's a good fix thanks!

dawsonfi commented 6 years ago

Hi @rogeriochaves

I'm Glad that you liked it. Feel free to merge it. And i'll create more PR's with the rest of the integration tests for the endpoints.

Also, i've added one extra commit today, just adding the unit tests into a mod test {}, that's recommended because it tells rust to ignore those tests when compiling the production code, increasing the compiling speed. :)

rogeriochaves commented 6 years ago

Merged! Btw circleci is now pulling the image from a public dockerhub repo, so next PRs should build just fine :D