So I have a REST backend (in node.js or Java doesn't matter but the example is in js).
I try to have a service for each endpoint so that the /users endpoint has two files:
usersRouter.js which includes the router endpoints with example code:
router.get('/users/:username',function(req,res,next){
return userService.find(username);
}
userService.js
function find(username) { //do some database stuff here }
I think best practices call for testing all methods in your app with both unit testing the service and integration testing the endpoint.
Is it really necessary in this case? If the endpoint only calls one method then I could test only this one with all the available scenarios.
A downside would be that the function has more options that are not used by the endpoint and could be used by another endpoint/function but is it too much to test almost the same thing twice?