Adds extra test for postgres case
All checks were successful
gitea-deepak/gogmagog/pipeline/head This commit looks good
All checks were successful
gitea-deepak/gogmagog/pipeline/head This commit looks good
This commit is contained in:
parent
9f5f5413d1
commit
e6158e680f
@ -97,6 +97,30 @@ func TestInsertPlan(t *testing.T) {
|
||||
|
||||
}
|
||||
|
||||
func TestInsertPlanErr(t *testing.T) {
|
||||
// setup
|
||||
assert := assert.New(t)
|
||||
|
||||
str, mock := getDbMock(t)
|
||||
planDate, _ := time.Parse("2006-01-02", "2021-01-01")
|
||||
plan := &models.Plan{PlanDate: planDate}
|
||||
|
||||
mock.ExpectBegin()
|
||||
mock.ExpectQuery("^INSERT INTO plans \\(plan_date\\) VALUES \\(\\$1\\) RETURNING plan_id$").
|
||||
WithArgs(planDate).
|
||||
WillReturnError(fmt.Errorf("example error"))
|
||||
mock.ExpectRollback()
|
||||
|
||||
// function under test
|
||||
_, err := str.InsertPlan(plan)
|
||||
// check results
|
||||
assert.NotNil(err)
|
||||
if err := mock.ExpectationsWereMet(); err != nil {
|
||||
t.Errorf("unfulfilled expectations: %s", err)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestErrPlanByID(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user