-
-
Save nolandubeau/9818b2715289ad739dad to your computer and use it in GitHub Desktop.
Unit Testing Issue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getUser(event,rc,prc){ | |
//load user record | |
rc.user = userService.getUser(arguments.prc.user_id,getcoldBoxOCM().get('activePartners')); | |
//validate user is not empty | |
if(structIsEmpty(rc.user)){ | |
if( log.canError() ){ | |
log.error("Invalid User Request |#arguments.rc.Authorization# from #cgi.REMOTE_ADDR#",arguments.rc); | |
} | |
rc.results.setStatus(404); | |
rc.results.addError(404,'User does not exist'); | |
}else{ | |
rc.results.setData(rc.user); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void function should_return_404_and_not_log_when_unable_to_obtain_a_user() | |
{ | |
var rc = { | |
authorization='UserTest', | |
results=Results | |
}; | |
var prc = { | |
user_id = 0 | |
}; | |
Log.$('canError',false).$('error'); | |
UserService.$('getUser',{}); | |
SUT.getUser(Event,rc,prc); | |
assertEquals(1,log.$count('canError'),'log.canError() method count failure'); | |
assertEquals(0,log.$count('error'),'log.error() method count failure'); | |
assertEquals(1,results.$count('setStatus'),'results.setStatus() method count failure'); | |
assertEquals(1,results.$count('addError'),'results.addError() method count failure'); | |
assertEquals(404,results.$callLog().setStatus[1]['1'],'order position of first argument is not as expected'); | |
assertEquals(404,results.$callLog().addError[1]['1'],'order position of first argument is not as expected'); | |
assertEquals('User does not exist',results.$callLog().addError[1]['2'],'error message is not as expected'); | |
/*writeDump(results.$callLog()); | |
abort;*/ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment