diff --git a/store/postgres_test.go b/store/postgres_test.go index 16e798e..af13ff8 100644 --- a/store/postgres_test.go +++ b/store/postgres_test.go @@ -265,6 +265,30 @@ func TestSelectActionsByPlanID(t *testing.T) { } } +func TestSelectActionsByPlanIDErr(t *testing.T) { + // set up test + assert := assert.New(t) + + idToUse := 1 + + str, mock := getDbMock(t) + + mock.ExpectQuery("^SELECT action_id, action_description, estimated_chunks, completed_chunks, completed_on, created_at, updated_at, plan_id FROM actions WHERE plan_id = \\$1$"). + WithArgs(idToUse). + WillReturnError(fmt.Errorf("example error")) + + // function under test + actions, err := str.SelectActionsByPlanID(&models.Plan{PlanID: int64(idToUse)}) + + // test results + assert.NotNil(err) + assert.Nil(actions) + + if err := mock.ExpectationsWereMet(); err != nil { + t.Errorf("unfulfilled expectations: %s", err) + } +} + func TestSelectActionById(t *testing.T) { // set up test assert := assert.New(t)