2016-04-01 22:25:16 +00:00
|
|
|
// Copyright IBM Corp. 2016. All Rights Reserved.
|
|
|
|
// Node module: loopback-datasource-juggler
|
|
|
|
// This file is licensed under the MIT License.
|
|
|
|
// License text available at https://opensource.org/licenses/MIT
|
|
|
|
|
2016-03-02 11:32:11 +00:00
|
|
|
var should = require('./init.js');
|
|
|
|
var DataSource = require('../lib/datasource.js').DataSource;
|
|
|
|
|
|
|
|
describe('DataSource', function() {
|
|
|
|
it('reports helpful error when connector init throws', function() {
|
|
|
|
var throwingConnector = {
|
|
|
|
name: 'loopback-connector-throwing',
|
|
|
|
initialize: function(ds, cb) {
|
|
|
|
throw new Error('expected test error');
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
(function() {
|
|
|
|
// this is what LoopBack does
|
|
|
|
return new DataSource({
|
|
|
|
name: 'dsname',
|
2016-04-01 11:48:17 +00:00
|
|
|
connector: throwingConnector,
|
2016-03-02 11:32:11 +00:00
|
|
|
});
|
|
|
|
}).should.throw(/loopback-connector-throwing/);
|
|
|
|
});
|
|
|
|
});
|