-
Notifications
You must be signed in to change notification settings - Fork 77
pollers unit-test for 2.0 and services #134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pollers unit-test for 2.0 and services #134
Conversation
|
👍 |
|
Interesting, no coveralls coverage check? |
|
@jlongever Does it need to be turned on ? If so, how? |
|
@srinia6 it should be on by default. not sure why it didn't run. |
spec/lib/api/2.0/pollers-spec.js
Outdated
| @@ -0,0 +1,330 @@ | |||
| // Copyright 2015, EMC, Inc. | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update to 2016
|
I just had a minor comment about the date, but other than that it looks good to me 👍 |
| destroyByIdentifier: sinon.stub().resolves() | ||
| }; | ||
|
|
||
| taskProtocol = helper.injector.get("Protocol.Task"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indent error
|
👎 for this, since I see a lot bad test case design. @srinia6 please help fix this |
|
|
||
| describe("patchPollersById", function() { | ||
| it('should expose the appropriate methods', function() { | ||
| pollerService.should.have.property('patchPollersById') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mixed double and single quotes.
Too many errors. (53% scanned).
| }); | ||
|
|
||
| it("should return error if specific poller info is not found", function () { | ||
| var mockPoller = {"message":"NotFoundError: Could not find workitem with identifier"}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@srinia6 I think we want to make this an error object: var mockPollerError = new Errors.NotFoundError('Could not find workitem with identifier').
| it("should return error if specific poller info is not found", function () { | ||
| var mockPollerError = new Errors.NotFoundError("Could not find workitem with identifier"); | ||
| waterline.workitems.needByIdentifier.rejects(mockPollerError); | ||
| return pollerService.getPollersById().should.eventually.be.rejectedWith(mockPollerError); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is too long.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ignoring this error.
|
LGTM +1 |
|
👍 after fix the hounci warning "Line is too long" |
|
👍 |
|
@srinia6 all houndci's review comments should be fixed. if it could be ignored, please comment it. 👍 after fix all houndci issues |
| }]; | ||
| waterline.workitems.needByIdentifier.withArgs({"id": "4532"}).resolves(mockPoller[0]); | ||
| waterline.workitems.needByIdentifier.withArgs({"id": "1234"}).resolves(mockPoller[1]); | ||
| Promise.all(["4532", "1234"].map(function(id, index) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just realized this promise has not been returned, this should be fixed before merge.
|
I have to withdraw my approval, because I still see a critical error: Meanwhile, the hounci warning about "Line is too long" should also be fixed. |
| }); | ||
|
|
||
| it("should return error if specific poller info is not found", function () { | ||
| var mockPollerError = new Errors.NotFoundError("Could not find workitem with identifier"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is too long.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ignoring this error.
|
|
test this please |
|
@srinia6, Ithink you miss another fix: the promise.map need be returned otherwise your assertion logic will not take effect. Meanwhile, for "Line is too long", if you do have reason to ignore it, you'd use jshint ignore synatx(please search jshint manual) and append it after the line you want to ingore. |
|
@yyscamper I looked at the test case. It is working as expected. The reason it was passing previously was the data [resolved] came back as undefined, and the index also was un-defined [so, the test case passed] . |
|
@srinia6 : understand the brackets design, your current code is OK for me. This is not a style problem, this is a problem about library/framework usage, so this need be fixed. If you add your assertion logic in the Promise, that promise must be returned, otherwise mocha will not wait the test case is actually done. I see all your code's Promises are returned except this one. Please refer to the mocha guideline about Promise: https://mochajs.org/#working-with-promises. |
|
👍 after fix the problem that Promise doesn't been returned |
|
@yyscamper : Not sure if I understood your concern. You suggested these changes! I did try substituting per your suggestion/concern i.e.- "** Just change the "expect(xxx).to.equal(xxx)" to the inverted logic "expect(xxx).to.not.equal(xxx)", you will find both pass!! **" I see "crisp" error showing-up as below: Unhandled rejection AssertionError: expected { Object (id, name, ...) } to not equal { Object (id, name, ...) } SO i am guessing it IS doing all the "right" thing? |
|
@yyscamper Fixed it. Turns out that i am not seeing the failing case because the promise is mocked-out (here). |
|
good 👍 . @srinia6 |
|
@RackHD/corecommitters - Can you review/merge this please? |
|
+1 |
pollers unit-test for 2.0 and services
@dalebremner @brianparry @geoff-reid @abildw @RackHD/corecommitters