Skip to content

Commit

Permalink
One more postgres error mapper test to make sure all lodash stuff sti…
Browse files Browse the repository at this point in the history
…ll works
  • Loading branch information
elhigu committed Apr 20, 2017
1 parent edd12c4 commit 01925ca
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions error-handler/error-handler.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ var config = {
]
};

describe.only('error-handlers express middleware', function () {
describe('error-handlers express middleware', function () {

var mockLogger = new logger.MockHandler();

Expand Down Expand Up @@ -121,7 +121,7 @@ describe.only('error-handlers express middleware', function () {
expect(mockRes.lastErr.statusCode).to.be(409);
});

it('should parse some pestgres error', function () {
it('should match parseForeignKeyViolationError postgres error', function () {
var theError = new Error('SQLITE_CONSTRAINT: UNIQUE diipadaa dappa huh.hah.hei');
theError.severity = 'pretty bad';
theError.code = '23503';
Expand All @@ -132,4 +132,16 @@ describe.only('error-handlers express middleware', function () {
expect(mockRes.lastErr.data.nasty).to.be.ok();
expect(mockRes.lastErr.statusCode).to.be(409);
});

it('should match parseUniqueViolationError postgres error', function () {
var theError = new Error('SQLITE_CONSTRAINT: UNIQUE diipadaa dappa huh.hah.hei');
theError.severity = 'pretty bad';
theError.code = '23505';
theError.detail = '(nasty)=(somthing) "poopy" did hit the fan';
theError.internalQuery = 'select * from fan where not poo';
theError.routine = 1;
mockApp.expressHandler(theError, mockReq, mockRes, null);
expect(mockRes.lastErr.data.nasty).to.contain('already exists');
expect(mockRes.lastErr.statusCode).to.be(409);
});
});

0 comments on commit 01925ca

Please sign in to comment.