mirror of
https://github.com/knex/knex.git
synced 2025-08-03 06:12:10 +00:00
41 lines
1.0 KiB
JavaScript
41 lines
1.0 KiB
JavaScript
![]() |
var knex = require('../../../knex');
|
||
|
|
||
|
describe("Postgres Unit Tests", function() {
|
||
|
|
||
|
it('Validates searchPath as Array/String', function() {
|
||
|
var knexInstance = knex({
|
||
|
client: 'pg',
|
||
|
});
|
||
|
|
||
|
expect(function() {
|
||
|
knexInstance.client.setSchemaSearchPath(null, {});
|
||
|
}).to.throw(TypeError);
|
||
|
|
||
|
expect(function() {
|
||
|
knexInstance.client.setSchemaSearchPath(null, 4);
|
||
|
}).to.throw(TypeError);
|
||
|
|
||
|
|
||
|
var fakeQueryFn = function(expectedSearchPath) {
|
||
|
return {
|
||
|
query: function(sql, callback) {
|
||
|
try {
|
||
|
expect(sql).to.equal('set search_path to ' + expectedSearchPath);
|
||
|
callback(null);
|
||
|
} catch(error) {
|
||
|
callback(error);
|
||
|
}
|
||
|
}
|
||
|
};
|
||
|
};
|
||
|
|
||
|
return knexInstance.client.setSchemaSearchPath(fakeQueryFn('"public,knex"'), 'public,knex')
|
||
|
.then(function() {
|
||
|
return knexInstance.client.setSchemaSearchPath(fakeQueryFn('"public","knex"'), ['public', 'knex']);
|
||
|
})
|
||
|
.then(function() {
|
||
|
return knexInstance.client.setSchemaSearchPath(fakeQueryFn('"public"'), 'public')
|
||
|
});
|
||
|
});
|
||
|
|
||
|
});
|