Skip to content
This repository was archived by the owner on Mar 11, 2022. It is now read-only.

Commit 7eb8bb8

Browse files
committed
Add error handling unit tests
1 parent 60140aa commit 7eb8bb8

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

test/client.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,35 @@ describe('CloudantClient', function() {
201201
});
202202
});
203203

204+
describe('Error Handling', function() {
205+
it('Propagate request error: Invalid protocol.', function(done) {
206+
var cloudantClient = new Client();
207+
cloudantClient.request('abc://localhost:5984', function(err) {
208+
assert.equal(err.message, 'Invalid protocol: abc:');
209+
done();
210+
});
211+
});
212+
213+
it('Propagate request error: Base URL must be type string.', function(done) {
214+
var cloudantClient = new Client();
215+
cloudantClient.request({ baseUrl: 123, url: '/_all_dbs' }, function(err) {
216+
assert.equal(err.message, 'options.baseUrl must be a string');
217+
done();
218+
});
219+
});
220+
221+
it('Propagate request error: `unix://` URL scheme is no longer supported.', function(done) {
222+
var cloudantClient = new Client();
223+
cloudantClient.request('unix://abc', function(err) {
224+
assert.equal(
225+
err.message,
226+
'`unix://` URL scheme is no longer supported. Please use the format `http://unix:SOCKET:PATH`'
227+
);
228+
done();
229+
});
230+
});
231+
});
232+
204233
describe('aborts request', function() {
205234
it('during plugin execution phase', function(done) {
206235
if (process.env.NOCK_OFF) {

0 commit comments

Comments
 (0)