From 6d104dc72a23fb8871b7661406342e65c9915ebc Mon Sep 17 00:00:00 2001 From: Deepak Date: Wed, 30 Dec 2020 11:11:52 -0600 Subject: [PATCH] adds missing test from postgres select actions by plan id --- store/postgres_test.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) 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)