Skip to content
This repository has been archived by the owner on Feb 23, 2019. It is now read-only.

Add a utils.assertSaneResponse method #139

Merged
merged 2 commits into from
Sep 19, 2017

Conversation

rhoggSugarcrm
Copy link
Contributor

This is the same as #109, but migrated to my new fork.

@rhoggSugarcrm
Copy link
Contributor Author

Low priority, so moving to Beta 6.

utils.js Outdated
*
* @param {ChakramResponse} response Object to check.
*/
assertSaneResponse: function assertSaneResponse(response) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would we want to also assertSaneResponse for _oauthRequest as well? That doesn't necessarily have to be done in this PR, but it's just something to think about.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I should definitely do that!

Copy link
Contributor

@khigakisugar khigakisugar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I approve the changes. I left some comments for @rhoggSugarcrm to review at his convenience, but they do not block the ability to merge this PR.

utils.js Outdated
*/
assertSaneResponse: function assertSaneResponse(response) {
if (!response) {
throw new Error('Undefined response received!');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually need to change this, I shouldn't say something is undefined if it could be some other falsy value.

@sugarcrm sugarcrm deleted a comment from coveralls Jul 11, 2017
@sugarcrm sugarcrm deleted a comment from coveralls Jul 11, 2017
@sugarcrm sugarcrm deleted a comment from coveralls Jul 11, 2017
@sugarcrm sugarcrm deleted a comment from coveralls Jul 11, 2017
@sugarcrm sugarcrm deleted a comment from coveralls Jul 11, 2017
@sugarcrm sugarcrm deleted a comment from coveralls Jul 11, 2017
@sugarcrm sugarcrm deleted a comment from coveralls Jul 11, 2017
@sugarcrm sugarcrm deleted a comment from coveralls Jul 11, 2017
tests/utils.js Outdated
@@ -107,6 +107,20 @@ describe('Utils', () => {
});
});

describe('assertSaneResponse', () => {
it('should throw on falsy response', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we keep the same naming pattern as in other test cases, namely: it should thrown an error ... ?

tests/utils.js Outdated
expect(() => { utils.assertSaneResponse(undefined); }).to.throw('Falsy response received!');
});

it('should throw if response.response does not exist', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing here.

utils.js Outdated
@@ -21,6 +21,21 @@ let chakram = require('chakram');
*/
let utils = {
/**
* Ensure that a Chakram response object is sane before using it.
* Throws if the response is unreasonable.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Throws an error?

Copy link
Contributor

@jcsmorais jcsmorais left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a couple suggestions, mainly nitpicks, otherwise looks great 👍

Signed-off-by: Bob Wombat Hogg <rhogg@sugarcrm.com>
@coveralls
Copy link

coveralls commented Sep 19, 2017

Coverage Status

Coverage increased (+0.06%) to 95.845% when pulling 3e3a7bf on rhoggSugarcrm:improve-error-logging into 2a66d5e on sugarcrm:master.

@sugarcrm sugarcrm deleted a comment from coveralls Sep 19, 2017
@rhoggSugarcrm rhoggSugarcrm merged commit 0a7363a into sugarcrm:master Sep 19, 2017
@rhoggSugarcrm rhoggSugarcrm deleted the improve-error-logging branch September 19, 2017 00:50
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants