remove modules from the cache & load test-helper
This commit is contained in:
parent
7103c044f1
commit
0d1054a874
@ -1,10 +1,34 @@
|
||||
// if (!assert) var assert = require('assert');
|
||||
var helper = require(__dirname+"/test-helper")
|
||||
, path = require('path')
|
||||
;
|
||||
|
||||
process.env.NODE_PG_FORCE_NATIVE = true;
|
||||
var paths = {
|
||||
'pg' : path.join(__dirname, '..', '..', '..', 'lib', 'index.js') ,
|
||||
'query_js' : path.join(__dirname, '..', '..', '..', 'lib', 'query.js') ,
|
||||
'query_native' : path.join(__dirname, '..', '..', '..', 'lib', 'native', 'query.js') ,
|
||||
};
|
||||
|
||||
var pg = require('../../../lib/');
|
||||
var query_native = require('../../../lib/native/query.js');
|
||||
var query_js = require('../../../lib/query.js');
|
||||
/**
|
||||
* delete the modules we are concerned about from the
|
||||
* module cache
|
||||
*/
|
||||
function deleteFromCache(){
|
||||
Object.keys(paths).forEach(function(module){
|
||||
var cache_key = paths[ module ];
|
||||
delete require.cache[ cache_key ];
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
deleteFromCache();
|
||||
process.env.NODE_PG_FORCE_NATIVE = "1";
|
||||
|
||||
var pg = require( paths.pg );
|
||||
var query_native = require( paths.query_native );
|
||||
var query_js = require( paths.query_js );
|
||||
|
||||
assert.deepEqual(pg.Client.Query, query_native);
|
||||
assert.notDeepEqual(pg.Client.Query, query_js);
|
||||
|
||||
deleteFromCache();
|
||||
delete process.env.NODE_PG_FORCE_NATIVE
|
||||
|
Loading…
Reference in New Issue
Block a user