mirror of
https://github.com/brianc/node-postgres.git
synced 2025-12-08 20:16:25 +00:00
change name of assert.raises to assert.emits
This commit is contained in:
parent
405fbbec12
commit
d2079478da
@ -3,6 +3,6 @@ var client = helper.client();
|
||||
|
||||
test("empty query message handling", function() {
|
||||
client.query("");
|
||||
assert.raises(client.connection, 'emptyQuery');
|
||||
assert.emits(client.connection, 'emptyQuery');
|
||||
client.on('drain', client.end.bind(client));
|
||||
});
|
||||
|
||||
@ -3,7 +3,7 @@ var helper = require(__dirname + '/test-helper');
|
||||
test('error handling', function(){
|
||||
var client = helper.client();
|
||||
client.query("select omfg from yodas_soda where pixistix = 'zoiks!!!'");
|
||||
assert.raises(client, 'error', function(error) {
|
||||
assert.emits(client, 'error', function(error) {
|
||||
assert.equal(error.severity, "ERROR");
|
||||
client.end();
|
||||
});
|
||||
|
||||
@ -26,7 +26,7 @@ test("noData message handling", function() {
|
||||
values: [101]
|
||||
});
|
||||
|
||||
assert.raises(query, 'row', function(row) {
|
||||
assert.emits(query, 'row', function(row) {
|
||||
assert.strictEqual(row.fields[0],100)
|
||||
});
|
||||
|
||||
|
||||
@ -8,11 +8,11 @@ test("simple, unnamed prepared statement", function(){
|
||||
values: ['Brian']
|
||||
});
|
||||
|
||||
assert.raises(query, 'row', function(row) {
|
||||
assert.emits(query, 'row', function(row) {
|
||||
assert.equal(row.fields[0], 20);
|
||||
});
|
||||
|
||||
assert.raises(query, 'end', function() {
|
||||
assert.emits(query, 'end', function() {
|
||||
client.end();
|
||||
});
|
||||
});
|
||||
@ -38,11 +38,11 @@ test("named prepared statement", function() {
|
||||
});
|
||||
});
|
||||
|
||||
assert.raises(query, 'row', function(row) {
|
||||
assert.emits(query, 'row', function(row) {
|
||||
assert.equal(row.fields[0], 'Brian');
|
||||
});
|
||||
|
||||
assert.raises(query, 'end', function() {
|
||||
assert.emits(query, 'end', function() {
|
||||
test("query was parsed", function() {
|
||||
assert.equal(parseCount, 1);
|
||||
});
|
||||
@ -56,11 +56,11 @@ test("named prepared statement", function() {
|
||||
values: [10, 'A%']
|
||||
});
|
||||
|
||||
assert.raises(cachedQuery, 'row', function(row) {
|
||||
assert.emits(cachedQuery, 'row', function(row) {
|
||||
assert.equal(row.fields[0], 'Aaron');
|
||||
});
|
||||
|
||||
assert.raises(cachedQuery, 'end', function() {
|
||||
assert.emits(cachedQuery, 'end', function() {
|
||||
test("query was only parsed one time", function() {
|
||||
assert.equal(parseCount, 1, "Should not have reparsed query");
|
||||
});
|
||||
@ -74,11 +74,11 @@ test("named prepared statement", function() {
|
||||
});
|
||||
|
||||
test("gets first row", function() {
|
||||
assert.raises(q, 'row', function(row) {
|
||||
assert.emits(q, 'row', function(row) {
|
||||
assert.equal(row.fields[0], "Aaron");
|
||||
|
||||
test("gets second row", function() {
|
||||
assert.raises(q, 'row', function(row) {
|
||||
assert.emits(q, 'row', function(row) {
|
||||
assert.equal(row.fields[0], "Brian");
|
||||
});
|
||||
});
|
||||
@ -86,7 +86,7 @@ test("named prepared statement", function() {
|
||||
});
|
||||
});
|
||||
|
||||
assert.raises(q, 'end', function() {
|
||||
assert.emits(q, 'end', function() {
|
||||
assert.equal(parseCount, 1);
|
||||
});
|
||||
});
|
||||
@ -111,12 +111,12 @@ test("prepared statements on different clients", function() {
|
||||
text: statement1
|
||||
});
|
||||
test('gets right data back', function() {
|
||||
assert.raises(query, 'row', function(row) {
|
||||
assert.emits(query, 'row', function(row) {
|
||||
assert.equal(row.fields[0], 26);
|
||||
});
|
||||
});
|
||||
|
||||
assert.raises(query, 'end', function() {
|
||||
assert.emits(query, 'end', function() {
|
||||
if(client2Finished) {
|
||||
client1.end();
|
||||
client2.end();
|
||||
@ -135,12 +135,12 @@ test("prepared statements on different clients", function() {
|
||||
});
|
||||
|
||||
test('gets right data', function() {
|
||||
assert.raises(query, 'row', function(row) {
|
||||
assert.emits(query, 'row', function(row) {
|
||||
assert.equal(row.fields[0], 1);
|
||||
});
|
||||
});
|
||||
|
||||
assert.raises(query, 'end', function() {
|
||||
assert.emits(query, 'end', function() {
|
||||
if(client1Finished) {
|
||||
client1.end();
|
||||
client2.end();
|
||||
|
||||
@ -13,7 +13,7 @@ test("simple query interface", function() {
|
||||
rows.push(row.fields[0])
|
||||
});
|
||||
|
||||
assert.raises(query, 'end', function() {
|
||||
assert.emits(query, 'end', function() {
|
||||
test("returned right number of rows", function() {
|
||||
assert.length(rows, 26);
|
||||
});
|
||||
@ -29,9 +29,9 @@ test("multiple simple queries", function() {
|
||||
client.query("create temp table bang(id serial, name varchar(5));insert into bang(name) VALUES('boom');")
|
||||
client.query("insert into bang(name) VALUES ('yes');");
|
||||
var query = client.query("select name from bang");
|
||||
assert.raises(query, 'row', function(row) {
|
||||
assert.emits(query, 'row', function(row) {
|
||||
assert.equal(row.fields[0], 'boom');
|
||||
assert.raises(query, 'row', function(row) {
|
||||
assert.emits(query, 'row', function(row) {
|
||||
assert.equal(row.fields[0],'yes');
|
||||
});
|
||||
});
|
||||
|
||||
@ -22,7 +22,7 @@ var testForTypeCoercion = function(type){
|
||||
});
|
||||
|
||||
test('coerces ' + val + ' as ' + type.name, function() {
|
||||
assert.raises(query, 'row', function(row) {
|
||||
assert.emits(query, 'row', function(row) {
|
||||
assert.strictEqual(row.fields[0], val);
|
||||
});
|
||||
});
|
||||
|
||||
@ -11,13 +11,13 @@ test('flushing once', function() {
|
||||
con.execute();
|
||||
con.flush();
|
||||
|
||||
assert.raises(con, 'parseComplete');
|
||||
assert.raises(con, 'bindComplete');
|
||||
assert.raises(con, 'dataRow');
|
||||
assert.raises(con, 'commandComplete', function(){
|
||||
assert.emits(con, 'parseComplete');
|
||||
assert.emits(con, 'bindComplete');
|
||||
assert.emits(con, 'dataRow');
|
||||
assert.emits(con, 'commandComplete', function(){
|
||||
con.sync();
|
||||
});
|
||||
assert.raises(con, 'readyForQuery', function(){
|
||||
assert.emits(con, 'readyForQuery', function(){
|
||||
con.end();
|
||||
});
|
||||
|
||||
@ -27,24 +27,24 @@ test('flushing once', function() {
|
||||
test("sending many flushes", function() {
|
||||
helper.connect(function(con) {
|
||||
|
||||
assert.raises(con, 'parseComplete', function(){
|
||||
assert.emits(con, 'parseComplete', function(){
|
||||
con.bind();
|
||||
con.flush();
|
||||
});
|
||||
|
||||
assert.raises(con, 'bindComplete', function(){
|
||||
assert.emits(con, 'bindComplete', function(){
|
||||
con.execute();
|
||||
con.flush();
|
||||
});
|
||||
|
||||
assert.raises(con, 'dataRow', function(msg){
|
||||
assert.emits(con, 'dataRow', function(msg){
|
||||
assert.equal(msg.fields[0], 1);
|
||||
assert.raises(con, 'dataRow', function(msg){
|
||||
assert.emits(con, 'dataRow', function(msg){
|
||||
assert.equal(msg.fields[0], 2);
|
||||
assert.raises(con, 'commandComplete', function(){
|
||||
assert.emits(con, 'commandComplete', function(){
|
||||
con.sync();
|
||||
});
|
||||
assert.raises(con, 'readyForQuery', function(){
|
||||
assert.emits(con, 'readyForQuery', function(){
|
||||
con.end();
|
||||
});
|
||||
});
|
||||
|
||||
@ -3,9 +3,9 @@ var helper = require(__dirname + '/test-helper');
|
||||
test('recieves notification from same connection with no payload', function() {
|
||||
helper.connect(function(con) {
|
||||
con.query('LISTEN boom');
|
||||
assert.raises(con, 'readyForQuery', function() {
|
||||
assert.emits(con, 'readyForQuery', function() {
|
||||
con.query("NOTIFY boom");
|
||||
assert.raises(con, 'notification', function(msg) {
|
||||
assert.emits(con, 'notification', function(msg) {
|
||||
assert.equal(msg.payload, "");
|
||||
assert.equal(msg.channel, 'boom')
|
||||
con.end();
|
||||
|
||||
@ -7,11 +7,11 @@ var rows = [];
|
||||
test('simple query', function() {
|
||||
helper.connect(function(con) {
|
||||
con.query('select * from ids');
|
||||
assert.raises(con, 'dataRow');
|
||||
assert.emits(con, 'dataRow');
|
||||
con.on('dataRow', function(msg) {
|
||||
rows.push(msg.fields);
|
||||
});
|
||||
assert.raises(con, 'readyForQuery', function() {
|
||||
assert.emits(con, 'readyForQuery', function() {
|
||||
con.end();
|
||||
});
|
||||
});
|
||||
|
||||
@ -17,7 +17,7 @@ assert.same = function(actual, expected) {
|
||||
};
|
||||
|
||||
|
||||
assert.raises = function(item, eventName, callback) {
|
||||
assert.emits = function(item, eventName, callback) {
|
||||
var called = false;
|
||||
var id = setTimeout(function() {
|
||||
test("Should have called " + eventName, function() {
|
||||
@ -62,7 +62,7 @@ assert.length = function(actual, expectedLength) {
|
||||
assert.equal(actual.length, expectedLength);
|
||||
};
|
||||
|
||||
['equal', 'length', 'empty', 'strictEqual', 'raises', 'equalBuffers', 'same', 'ok'].forEach(function(name) {
|
||||
['equal', 'length', 'empty', 'strictEqual', 'emits', 'equalBuffers', 'same', 'ok'].forEach(function(name) {
|
||||
var old = assert[name];
|
||||
assert[name] = function() {
|
||||
test.assertCount++
|
||||
|
||||
@ -54,7 +54,7 @@ test('bound command', function() {
|
||||
values: ['hi']
|
||||
});
|
||||
|
||||
assert.raises(query,'end', function() {
|
||||
assert.emits(query,'end', function() {
|
||||
test('parse argument', function() {
|
||||
assert.equal(parseArg.name, null);
|
||||
assert.equal(parseArg.text, 'select * where name = $1');
|
||||
|
||||
@ -82,13 +82,13 @@ test('executing query', function() {
|
||||
});
|
||||
|
||||
test('handles dataRow messages', function() {
|
||||
assert.raises(query, 'row', function(row) {
|
||||
assert.emits(query, 'row', function(row) {
|
||||
assert.equal(row.fields[0], "hi");
|
||||
});
|
||||
var handled = con.emit('dataRow', { fields: ["hi"] });
|
||||
assert.ok(handled, "should have handled first data row message");
|
||||
|
||||
assert.raises(query, 'row', function(row) {
|
||||
assert.emits(query, 'row', function(row) {
|
||||
assert.equal(row.fields[0], "bye");
|
||||
});
|
||||
var handledAgain = con.emit('dataRow', { fields: ["bye"] });
|
||||
@ -104,7 +104,7 @@ test('executing query', function() {
|
||||
});
|
||||
|
||||
test('removes itself after another readyForQuery message', function() {
|
||||
assert.raises(query, "end", function(msg) {
|
||||
assert.emits(query, "end", function(msg) {
|
||||
//TODO do we want to check the complete messages?
|
||||
});
|
||||
con.emit("readyForQuery");
|
||||
|
||||
@ -71,7 +71,7 @@ test('typed results', function() {
|
||||
fields: tests
|
||||
});
|
||||
|
||||
assert.raises(query, 'row', function(row) {
|
||||
assert.emits(query, 'row', function(row) {
|
||||
for(var i = 0; i < tests.length; i++) {
|
||||
test('parses ' + tests[i].name, function() {
|
||||
assert.strictEqual(row.fields[i], tests[i].expected);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user