Skip to content
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

test: migrate inspect and remote proxy tests to tap #198

Closed
wants to merge 1 commit into from

Conversation

nechaido
Copy link
Member

@nechaido nechaido commented May 31, 2017

Refs: #145
Refs: #146
Refs: #53.

test.assert(error, 'must return an error');
test.equal(error.code, jstp.ERR_INTERFACE_NOT_FOUND,
'error must be an ERR_INTERFACE_NOT_FOUND'
);
Copy link
Member

Choose a reason for hiding this comment

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

Maybe merge this line with the previous one?

@nechaido
Copy link
Member Author

Blocked until #190.

@aqrln
Copy link
Member

aqrln commented Jun 1, 2017

Still LGTM.

@aqrln
Copy link
Member

aqrln commented Jun 1, 2017

Oh, only one more thing: can please test connection.inspectInterface() directly too?

},
someOtherService: {
method(connection, argument, callback) {
callback(argument);
Copy link
Member

Choose a reason for hiding this comment

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

Is returning argument as an error intentional here?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's stub that is never called, but I'll fix it to behave properly if called

const expectedInterfaces = Object.keys(app.interfaces);
let expectedTests = 1;
expectedInterfaces.forEach((iface) => {
expectedTests += 1;
Copy link
Member

Choose a reason for hiding this comment

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

May you merge this with the next line? Like this:

expectedTests += Object.keys(app.interfaces[iface]).length + 1;

Copy link
Member Author

Choose a reason for hiding this comment

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

I'd like to leave it this way because it "separates" check count for interfaces and methods.

Copy link
Member

Choose a reason for hiding this comment

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

@nechaido, if that's the case, may you add a comment explaining this, to avoid confusion in the future?
Also, why not just add expectedInterfaces.length to expectedTests immediately after initialization, or even initialize expectedTests with expectedInterfaces.length + 1?

Copy link
Member Author

Choose a reason for hiding this comment

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

@belochub I though It'll be more obvious, seems It's not, also I'm strongly opposed to leaving a comment. It should be written in a more obvious way that needs no explanation. Maybe I'll stop on my initial idea: also proposed by you:

let expectedTests = 1 + expectedInterfaces.length;
expectedTests +=  expectedInterfaces.reduce((methodsCount, iface) => {
    methodsCount += Object.keys(app.interfaces[iface]).length;
  });

Maybe I should merge this into one expression.
@metarhia/jstp do you have any ideas concerning this issue?

Copy link
Member Author

@nechaido nechaido Jun 1, 2017

Choose a reason for hiding this comment

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

Or even:

let expectedTests = 1 + expectedInterfaces.reduce((tests, iface) => 
    tests + 1 + Object.keys(app.interfaces[iface]).length);

Copy link
Member

Choose a reason for hiding this comment

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

The latter looks better to me, but I think it's better to add a comment explaining this.

expectedInterfaces.forEach((iface) => {
connection.inspectInterface(iface, (error, methods) => {
test.assertNot(error, `must inspect ${iface}`);
Object.keys(app.interfaces[iface]).forEach((method) => {
Copy link
Member

Choose a reason for hiding this comment

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

You may avoid using braces and parenthesis here, there is just one statement in this function.


expectedInterfaces.forEach((iface) => {
test.assert(iface in api, `api must include '${iface}'`);
Object.keys(app.interfaces[iface]).forEach((method) => {
Copy link
Member

Choose a reason for hiding this comment

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

Ditto.

@nechaido nechaido requested a review from belochub June 2, 2017 16:21
@nechaido
Copy link
Member Author

nechaido commented Jun 2, 2017

@aqrln added.

);
});

test.test('must throw error if interface does not exist', (test) => {
Copy link
Member

Choose a reason for hiding this comment

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

It doesn't really throw, it just returns an error.

Copy link
Member

@belochub belochub left a comment

Choose a reason for hiding this comment

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

LGTM

nechaido added a commit that referenced this pull request Jun 2, 2017
Refs: #145
Refs: #146
Refs: #53
PR-URL: #198
Reviewed-By: Mykola Bilochub <nbelochub@gmail.com>
Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com>
@nechaido
Copy link
Member Author

nechaido commented Jun 2, 2017

Landed in 6be836e.

belochub pushed a commit that referenced this pull request Jan 22, 2018
Refs: #145
Refs: #146
Refs: #53
PR-URL: #198
Reviewed-By: Mykola Bilochub <nbelochub@gmail.com>
Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com>
belochub pushed a commit that referenced this pull request Jan 22, 2018
Refs: #145
Refs: #146
Refs: #53
PR-URL: #198
Reviewed-By: Mykola Bilochub <nbelochub@gmail.com>
Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com>
@belochub belochub mentioned this pull request Jan 22, 2018
belochub pushed a commit to metarhia/mdsf that referenced this pull request Jul 19, 2018
Refs: metarhia/jstp#145
Refs: metarhia/jstp#146
Refs: metarhia/jstp#53
PR-URL: metarhia/jstp#198
Reviewed-By: Mykola Bilochub <nbelochub@gmail.com>
Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com>
belochub pushed a commit to metarhia/mdsf that referenced this pull request Jul 19, 2018
Refs: metarhia/jstp#145
Refs: metarhia/jstp#146
Refs: metarhia/jstp#53
PR-URL: metarhia/jstp#198
Reviewed-By: Mykola Bilochub <nbelochub@gmail.com>
Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants