lucasmontano / twitch

[EBS] Channel's Top Visitors
https://www.twitch.tv/lucas_montano
119 stars 15 forks source link

Write unity tests for database operation functions and clean the code #26

Closed powilliam closed 4 years ago

powilliam commented 4 years ago

Motivation

Assuming that we need tests to have sure about if each piece of code is working we need test each piece of code. So to do that, we need write each class/method separately and that's why i changed a little of the project structure. Also i cleaned the code because functions like fetchTopParticipants was also updating the topParticipants array and incrementParticipantPoints was creating a participant when he doesn't exist. By this way each function fit on the single responsibility principle

About testing database operations, i used the MongoDB Memory Server that uses the last mongod binary so it's unnecessary create two databases to test everything.

Also i resolved that TODO comment about returning just the name and the points of a viewer

Changes