Skip to content

expanded discovery calls #350

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

Merged
merged 4 commits into from
Dec 12, 2016
Merged

expanded discovery calls #350

merged 4 commits into from
Dec 12, 2016

Conversation

kognate
Copy link
Contributor

@kognate kognate commented Dec 7, 2016

Adds ability to create collections and add documents

nock.disableNetConnect();
nock(service.url)
.persist()
.post(paths.environments + '?version=' + service.version_date)
Copy link
Contributor

Choose a reason for hiding this comment

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

I prefer individual nock()'s per test but not a blocker. (And I know a ton of our existing tests use this pattern...)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I copied this from the v1-experimental tests.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yea.. after I looked more thoroughly, these aren't even being used because the tests are all sync - see my later comments

Copy link
Contributor

@nfriedly nfriedly left a comment

Choose a reason for hiding this comment

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

Mostly good, but a couple of things need changed with the version and url, and possibly some of the jsdoc.

* Initial release
* @type {string}
*/
DiscoveryV1.VERSION_DATE_2016_07_11 = '2016-11-07';
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this the correct version_date for the GA release?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed

*
* @param {Object} params
* @param {String} params.environment_id
* @param {String} [params.name] Find collections with the given name.
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see params.name used anywhere in this method.

(It looks like this is also wrong in https://github.com/watson-developer-cloud/node-sdk/blob/master/discovery/v1-experimental.js#L103 )

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed. and it's right in experimental.

* @param params
* @param {String} params.environment_id environment guid for the collection
* @param {string} params.collection_id the guid of the collection to delete
* @param {file} params.file a file to post (smaller than 50mb)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this should be {Buffer|ReadableStream|Object} rather than {file} (?)

(Object allows you to specify filename and/or content type, e.g. {value: Buffer, options: contentType: 'text/foo'}.. or something like that.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed

* @param {string} params.collection_id the guid of the collection to delete
* @param {file} params.file a file to post (smaller than 50mb)
* @param {string} [params.configuration_id] config guid
* @param {string} [params.metadata] file metadata, including content-type (will infer if missing)
Copy link
Contributor

@nfriedly nfriedly Dec 8, 2016

Choose a reason for hiding this comment

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

What should params.metada look like?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

they should look at the docs. at least isn't that what the other discussion concluded?


util.inherits(DiscoveryV1, BaseService);
DiscoveryV1.prototype.name = 'discovery';
DiscoveryV1.prototype.version = 'v1-experimental';
Copy link
Contributor

Choose a reason for hiding this comment

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

This should just be v1

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done.

Copy link
Contributor

Choose a reason for hiding this comment

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

BTW, I'm not seeing the change in the PR - perhaps you put it in a different branch or forgot to push it to github?

util.inherits(DiscoveryV1, BaseService);
DiscoveryV1.prototype.name = 'discovery';
DiscoveryV1.prototype.version = 'v1-experimental';
DiscoveryV1.URL = 'https://gateway.watsonplatform.net/discovery-experimental/api';
Copy link
Contributor

@nfriedly nfriedly Dec 8, 2016

Choose a reason for hiding this comment

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

Presumably this shouldn't have -experimental in the URL either (?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nope.

});

it('should check no parameters provided (negative test)', function() {
discovery.getEnvironments({}, missingParameter);
Copy link
Contributor

Choose a reason for hiding this comment

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

This test doesn't make any sense. It passes regardless of weather or not getEnvironments() throws a missingParameter error. (Because the test is sync, but if getEnvironments doesn't throw an error, then fires the callback async - so the test has already passed by the time missingParameter throws). I think we should probably make the callback always async, and make missingParameter accept a callback.

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've no idea what that was doing there. removed.

threw = true;
assert.equal(err.message, 'Argument error: version_date was not specified, use DiscoveryV1.VERSION_DATE_2016_07_11');
}
assert(threw, 'should throw an error')
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good to know. I copied that pattern from another test. fixed.

.delete(paths.delete_document + '?version=' + service.version_date)
.reply(200, {'delete_doc': 'yes'})
.get(paths.configurations + '?version=' + service.version_date)
.reply(200, {'configs': 'yes'});
Copy link
Contributor

Choose a reason for hiding this comment

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

FYI: these don't hurt, but nock can't check things in time for for sync tests because the test passes before nock gets called, and any error that nock might throw gets swallowed by mocha because it occurs outside of a test :/


util.inherits(DiscoveryV1, BaseService);
DiscoveryV1.prototype.name = 'discovery';
DiscoveryV1.prototype.version = 'v1-experimental';
Copy link
Contributor

Choose a reason for hiding this comment

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

BTW, I'm not seeing the change in the PR - perhaps you put it in a different branch or forgot to push it to github?

@kognate
Copy link
Contributor Author

kognate commented Dec 12, 2016

@nfriedly I did miss a file. it's in now.

Copy link
Contributor

@nfriedly nfriedly left a comment

Choose a reason for hiding this comment

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

Awesome!

@nfriedly nfriedly merged commit c2a0c89 into master Dec 12, 2016
@nfriedly nfriedly deleted the issues/discovery_phase_two branch December 12, 2016 16:20
@nfriedly
Copy link
Contributor

Should be released in v2.14.0 shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants