change assert.length to assert.lengthIs

This commit is contained in:
brianc 2011-10-10 19:21:06 -05:00
parent 1ab5e8ae9e
commit afe4382c63
15 changed files with 29 additions and 27 deletions

View File

@ -31,7 +31,7 @@ test('api', function() {
test('simple query execution',assert.calls( function() {
log("executing simple query")
client.query("SELECT * FROM band WHERE name = 'the beach boys'", assert.calls(function(err, result) {
assert.length(result.rows, 1)
assert.lengthIs(result.rows, 1)
assert.equal(result.rows.pop().name, 'the beach boys')
log("simple query executed")
}));
@ -42,14 +42,14 @@ test('api', function() {
log("executing prepared statement 1")
client.query('SELECT * FROM band WHERE name = $1', ['dead black hearts'],assert.calls( function(err, result) {
log("Prepared statement 1 finished")
assert.length(result.rows, 1);
assert.lengthIs(result.rows, 1);
assert.equal(result.rows.pop().name, 'dead black hearts');
}))
log("executing prepared statement two")
client.query('SELECT * FROM band WHERE name LIKE $1 ORDER BY name', ['the %'], assert.calls(function(err, result) {
log("prepared statement two finished")
assert.length(result.rows, 2);
assert.lengthIs(result.rows, 2);
assert.equal(result.rows.pop().name, 'the flaming lips');
assert.equal(result.rows.pop().name, 'the beach boys');
sink.add();

View File

@ -10,7 +10,7 @@ test('parsing array results', function() {
test('numbers', function() {
// client.connection.on('message', console.log)
client.query('SELECT numbors FROM why', assert.success(function(result) {
assert.length(result.rows[0].numbors, 3);
assert.lengthIs(result.rows[0].numbors, 3);
assert.equal(result.rows[0].numbors[0], 1);
assert.equal(result.rows[0].numbors[1], 2);
assert.equal(result.rows[0].numbors[2], 3);
@ -20,7 +20,7 @@ test('parsing array results', function() {
test('parses string arrays', function() {
client.query('SELECT names FROM why', assert.success(function(result) {
var names = result.rows[0].names;
assert.length(names, 3);
assert.lengthIs(names, 3);
assert.equal(names[0], 'aaron');
assert.equal(names[1], 'brian');
assert.equal(names[2], "a b c");

View File

@ -54,14 +54,14 @@ var runBigQuery = function(client) {
console.log(err);
throw Err;
}
assert.length(result.rows, 26);
assert.lengthIs(result.rows, 26);
});
q.on('row', function(row) {
rows.push(row);
})
assert.emits(q, 'end', function() {
//query ended
assert.length(rows, 26);
assert.lengthIs(rows, 26);
})
}

View File

@ -115,6 +115,7 @@ test('non-error calls supplied callback', function() {
});
test('when connecting to invalid host', function() {
return false;
var client = new Client({
user: 'brian',
password: '1234',
@ -125,6 +126,7 @@ test('when connecting to invalid host', function() {
});
test('when connecting to invalid host with callback', function() {
return false;
var client = new Client({
user: 'brian',
password: '1234',

View File

@ -19,14 +19,14 @@ test("simple query interface", function() {
columnCount++;
};
if ('length' in row) {
assert.length(row, columnCount, 'Iterating through the columns gives a different length from calling .length.');
assert.lengthIs(row, columnCount, 'Iterating through the columns gives a different length from calling .length.');
}
});
});
assert.emits(query, 'end', function() {
test("returned right number of rows", function() {
assert.length(rows, 26);
assert.lengthIs(rows, 26);
});
test("row ordering", function(){
assert.equal(rows[0], "Aaron");

View File

@ -24,7 +24,7 @@ pg.connect(conString, assert.success(function(client) {
//kill the connection from client
client2.query(killIdleQuery, assert.success(function(res) {
//check to make sure client connection actually was killed
assert.length(res.rows, 1);
assert.lengthIs(res.rows, 1);
}));
}));
}));

View File

@ -15,7 +15,7 @@ var testPoolSize = function(max) {
helper.pg.connect(conString, function(err, client) {
assert.isNull(err);
client.query("select * from person", function(err, result) {
assert.length(result.rows, 26)
assert.lengthIs(result.rows, 26)
})
client.query("select count(*) as c from person", function(err, result) {
assert.equal(result.rows[0].c, 26)

View File

@ -93,7 +93,7 @@ assert.equalBuffers = function(actual, expected) {
};
assert.empty = function(actual) {
assert.length(actual, 0);
assert.lengthIs(actual, 0);
};
assert.success = function(callback) {
@ -116,7 +116,7 @@ assert.throws = function(offender) {
assert.ok(false, "Expected " + offender + " to throw exception");
}
assert.length = function(actual, expectedLength) {
assert.lengthIs = function(actual, expectedLength) {
assert.equal(actual.length, expectedLength);
};

View File

@ -8,7 +8,7 @@ test('cleartext password authentication', function(){
client.connection.emit('authenticationCleartextPassword');
test('responds with password', function() {
var packets = client.connection.stream.packets;
assert.length(packets, 1);
assert.lengthIs(packets, 1);
var packet = packets[0];
assert.equalBuffers(packet, [0x70, 0, 0, 0, 6, 33, 0]);
});

View File

@ -6,7 +6,7 @@ test('md5 authentication', function() {
client.connection.emit('authenticationMD5Password', {salt: salt});
test('responds', function() {
assert.length(client.connection.stream.packets, 1);
assert.lengthIs(client.connection.stream.packets, 1);
test('should have correct encrypted data', function() {
var encrypted = Client.md5(client.password + client.user);
encrypted = Client.md5(encrypted + salt.toString('binary'));

View File

@ -64,7 +64,7 @@ test('bound command', function() {
test('bind argument', function() {
assert.equal(bindArg.statement, null);
assert.equal(bindArg.portal, null);
assert.length(bindArg.values, 1);
assert.lengthIs(bindArg.values, 1);
assert.equal(bindArg.values[0], 'hi')
});

View File

@ -7,7 +7,7 @@ var testForTag = function(tagText, callback) {
client.connection.emit('readyForQuery')
var query = client.query("whatever");
assert.length(client.connection.queries, 1)
assert.lengthIs(client.connection.queries, 1)
assert.emits(query, 'end', function(result) {
assert.ok(result != null, "should pass something to this event")

View File

@ -9,7 +9,7 @@ test('executing query', function() {
assert.empty(client.connection.queries);
client.connection.emit('readyForQuery');
client.query('yes');
assert.length(client.connection.queries, 1);
assert.lengthIs(client.connection.queries, 1);
assert.equal(client.connection.queries, 'yes');
});
@ -23,7 +23,7 @@ test('executing query', function() {
test('sends query to connection once ready', function() {
assert.ok(client.connection.emit('readyForQuery'));
assert.length(client.connection.queries, 1);
assert.lengthIs(client.connection.queries, 1);
assert.equal(client.connection.queries[0], "boom");
});
@ -40,20 +40,20 @@ test('executing query', function() {
test("after one ready for query",function() {
connection.emit('readyForQuery');
assert.length(queries, 1);
assert.lengthIs(queries, 1);
assert.equal(queries[0], "one");
});
test('after two ready for query', function() {
connection.emit('readyForQuery');
assert.length(queries, 2);
assert.lengthIs(queries, 2);
});
test("after a bunch more", function() {
connection.emit('readyForQuery');
connection.emit('readyForQuery');
connection.emit('readyForQuery');
assert.length(queries, 3);
assert.lengthIs(queries, 3);
assert.equal(queries[0], "one");
assert.equal(queries[1], 'two');
assert.equal(queries[2], 'three');
@ -72,7 +72,7 @@ test('executing query', function() {
test('sends query on readyForQuery event', function() {
con.emit('readyForQuery');
assert.length(con.queries, 1);
assert.lengthIs(con.queries, 1);
assert.equal(con.queries[0], 'whatever');
});

View File

@ -367,7 +367,7 @@ test('split buffer, single message parsing', function() {
test('parses when full buffer comes in', function() {
stream.emit('data', fullBuffer);
assert.length(message.fields, 5);
assert.lengthIs(message.fields, 5);
assert.equal(message.fields[0], null);
assert.equal(message.fields[1], "bang");
assert.equal(message.fields[2], "zug zug");
@ -382,7 +382,7 @@ test('split buffer, single message parsing', function() {
fullBuffer.copy(secondBuffer, 0, firstBuffer.length);
stream.emit('data', firstBuffer);
stream.emit('data', secondBuffer);
assert.length(message.fields, 5);
assert.lengthIs(message.fields, 5);
assert.equal(message.fields[0], null);
assert.equal(message.fields[1], "bang");
assert.equal(message.fields[2], "zug zug");
@ -425,7 +425,7 @@ test('split buffer, multiple message parsing', function() {
var verifyMessages = function() {
assert.length(messages, 2);
assert.lengthIs(messages, 2);
assert.same(messages[0],{
name: 'dataRow',
fieldCount: 1

View File

@ -6,7 +6,7 @@ var con = new Connection({
});
assert.received = function(stream, buffer) {
assert.length(stream.packets, 1);
assert.lengthIs(stream.packets, 1);
var packet = stream.packets.pop();
assert.equalBuffers(packet, buffer);
};