How to unit test exception-path ?

6 views
Skip to first unread message

Tanmoy Pal

unread,
Jul 21, 2016, 2:58:36 PM7/21/16
to Sequelize
In my application I have an API to delete records from postgreSQL through Sequelize. I am using model.destroy() to achieve this. I am also catching Sequelize exception here. Now I want to Unit Test this error path to see how the application behaves when some sequelize database error occurs during record deletion. Could you please suggest me the best way to get it done ?

Mick Hansen

unread,
Jul 21, 2016, 3:04:45 PM7/21/16
to Tanmoy Pal, Sequelize
Stub out the method and return a rejection

On Thu, Jul 21, 2016 at 8:58 PM, Tanmoy Pal <tanmoy...@gmail.com> wrote:
In my application I have an API to delete records from postgreSQL through Sequelize. I am using model.destroy() to achieve this. I am also catching Sequelize exception here. Now I want to Unit Test this error path to see how the application behaves when some sequelize database error occurs during record deletion. Could you please suggest me the best way to get it done ?



--
Mick Hansen
@mhansendev
mhansen.io
Reply all
Reply to author
Forward
0 new messages