delete the entire module cache

This commit is contained in:
Hannes Hörl 2013-06-29 10:15:39 +02:00
parent 0d1054a874
commit b313a392a7

View File

@ -1,3 +1,8 @@
/**
* helper needs to be loaded for the asserts but it alos proloads
* client which we don't want here
*
*/
var helper = require(__dirname+"/test-helper")
, path = require('path')
;
@ -10,18 +15,17 @@ var paths = {
/**
* delete the modules we are concerned about from the
* module cache
* module cache, so they get loaded cleanly and the env
* var can kick in ...
*/
function deleteFromCache(){
Object.keys(paths).forEach(function(module){
var cache_key = paths[ module ];
delete require.cache[ cache_key ];
function emptyCache(){
Object.keys(require.cache).forEach(function(key){
delete require.cache[key];
});
};
deleteFromCache();
process.env.NODE_PG_FORCE_NATIVE = "1";
emptyCache();
process.env.NODE_PG_FORCE_NATIVE = '1';
var pg = require( paths.pg );
var query_native = require( paths.query_native );
@ -30,5 +34,5 @@ var query_js = require( paths.query_js );
assert.deepEqual(pg.Client.Query, query_native);
assert.notDeepEqual(pg.Client.Query, query_js);
deleteFromCache();
emptyCache();
delete process.env.NODE_PG_FORCE_NATIVE