removed some globals from tests

This commit is contained in:
Brian Carlson 2011-02-23 19:50:43 -06:00
parent 8fe4f85714
commit 7d05daaf2c
11 changed files with 26 additions and 18 deletions

View File

@ -60,6 +60,7 @@ p._pulseQueryQueue = function() {
}
var ctor = function(config) {
console.log('creating native client');
var connection = new Connection();
connection._queryQueue = [];
connection._activeQuery = null;

View File

@ -14,7 +14,7 @@ var sink = new helper.Sink(5, 10000, function() {
test('api', function() {
log("connecting to %s", connectionString)
pg.connect(connectionString, assert.calls(function(err, client) {
assert.equal(err, null, "Failed to connect: " + sys.inspect(err));
assert.equal(err, null, "Failed to connect: " + helper.sys.inspect(err));
client.query('CREATE TEMP TABLE band(name varchar(100))');

View File

@ -1,6 +1,6 @@
var net = require('net');
var helper = require(__dirname+'/../test-helper');
var Connection = require('connection');
var connect = function(callback) {
var username = helper.args.user;
var database = helper.args.database;

View File

@ -1,18 +1,18 @@
require.paths.unshift(__dirname + '/../lib/');
EventEmitter = require('events').EventEmitter;
sys = require('sys');
//make assert a global...
assert = require('assert');
BufferList = require(__dirname+'/buffer-list')
buffers = require(__dirname + '/test-buffers');
Connection = require('connection');
var EventEmitter = require('events').EventEmitter;
var sys = require('sys');
var BufferList = require(__dirname+'/buffer-list')
var Connection = require('connection');
var args = require(__dirname + '/cli');
if(args.libpq) {
Client = require('binding').Client;
Client = require('binding').Client;
} else {
Client = require('client');
Client = require('client');
}
process.on('uncaughtException', function(d) {
@ -210,7 +210,9 @@ module.exports = {
pg: require('index'),
connectionString: function() {
return "pg"+(count++)+"://"+args.user+":"+args.password+"@"+args.host+":"+args.port+"/"+args.database;
}
},
sys: sys,
Client: Client
};

View File

@ -1,4 +1,5 @@
var helper = require(__dirname + '/test-helper');
var Connection = require('connection');
var con = new Connection({stream: "NO"});
var client = new Client({connection:con});

View File

@ -1,5 +1,5 @@
require(__dirname+'/../test-helper');
var Connection = require('connection');
var makeClient = function() {
var connection = new Connection({stream: "no"});
connection.startup = function() {};

View File

@ -1,5 +1,5 @@
var helper = require(__dirname + '/test-helper');
var Connection = require('connection');
var con = new Connection({stream: new MemoryStream()});
test("connection emits stream errors", function() {
assert.emits(con, 'error', function(err) {

View File

@ -1,5 +1,6 @@
require(__dirname+'/test-helper');
var Connection = require('connection');
var buffers = require(__dirname + '/../../test-buffers');
var PARSE = function(buffer) {
return new Parser(buffer).parse();
};

View File

@ -1,4 +1,5 @@
require(__dirname + "/test-helper");
var Connection = require('connection');
var stream = new MemoryStream();
var con = new Connection({
stream: stream

View File

@ -1,5 +1,5 @@
require(__dirname+'/test-helper');
var Connection = require('connection');
test('connection can take existing stream', function() {
var stream = new MemoryStream();
var con = new Connection({stream: stream});

View File

@ -1,10 +1,12 @@
require(__dirname+'/../test-helper');
var helper = require(__dirname+'/../test-helper');
var EventEmitter = require('events').EventEmitter;
var Connection = require('connection');
MemoryStream = function() {
EventEmitter.call(this);
this.packets = [];
};
sys.inherits(MemoryStream, EventEmitter);
helper.sys.inherits(MemoryStream, EventEmitter);
var p = MemoryStream.prototype;