-
Notifications
You must be signed in to change notification settings - Fork 664
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
Conversation
nock.disableNetConnect(); | ||
nock(service.url) | ||
.persist() | ||
.post(paths.environments + '?version=' + service.version_date) |
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.
I prefer individual nock()
's per test but not a blocker. (And I know a ton of our existing tests use this pattern...)
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.
Yeah, I copied this from the v1-experimental tests.
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.
Yea.. after I looked more thoroughly, these aren't even being used because the tests are all sync - see my later comments
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.
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'; |
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.
Is this the correct version_date for the GA release?
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.
changed
* | ||
* @param {Object} params | ||
* @param {String} params.environment_id | ||
* @param {String} [params.name] Find collections with the given name. |
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.
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 )
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.
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) |
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.
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.)
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.
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) |
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.
What should params.metada look like?
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.
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'; |
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.
This should just be v1
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.
done.
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.
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'; |
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.
Presumably this shouldn't have -experimental
in the URL either (?)
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.
nope.
}); | ||
|
||
it('should check no parameters provided (negative test)', function() { | ||
discovery.getEnvironments({}, missingParameter); |
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.
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.
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.
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') |
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.
BTW, there is an assert.throws
method ;)
https://nodejs.org/api/assert.html#assert_assert_throws_block_error_message
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.
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'}); |
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.
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'; |
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.
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?
@nfriedly I did miss a file. it's in now. |
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.
Awesome!
Should be released in |
Adds ability to create collections and add documents