Skip to content

Commit

Permalink
Release 0.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
thepeak99 committed May 30, 2015
1 parent 48d557c commit 7ffd1f0
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

node-postgres-test is a module that provides easy unit testing for the popular [node-postgres](https://github.com/brianc/node-postgres).

## Install
npm install pgtest

## Example
```javascript

Expand All @@ -15,7 +18,7 @@ pgtest.expect('SELECT * FROM vegetables').returning(null, [
]);

pgtest.connect('foo', function (err, client, done) {
client.query('SELECT * FROM vegetables', function(err, data) {
client.query('SELECT * FROM vegetables', function (err, data) {
console.log(data);
done();
});
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pgtest",
"version": "0.1.1",
"version": "0.2.0",
"description": "A module that provides easy unit-testing for the popular node-postgres.",
"main": "lib/pgtest.js",
"scripts": {
Expand Down
18 changes: 18 additions & 0 deletions test/test-pgtest.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,24 @@ describe('pgtest', function () {
pgtest.reset(true);
});

describe('Docs', function () {
it('should run the example in README', function () {
pgtest.expect('SELECT * FROM vegetables').returning(null, [
[ 'potatoes', '1kg' ],
[ 'tomatoes', '500g' ]
]);

pgtest.connect('foo', function (err, client, done) {
client.query('SELECT * FROM vegetables', function (err, data) {
expect(data).to.be.deep.equal({ rows: [ [ 'potatoes', '1kg' ], [ 'tomatoes', '500g' ] ] });
done();
});
});

pgtest.check(); //No errors
});
});

describe('connect', function () {
it('should call its callback with a client and a done function', function (testDone) {
pgtest.connect('foo', function (err, client, done) {
Expand Down

0 comments on commit 7ffd1f0

Please sign in to comment.