adds full action fields to struct
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:
@@ -53,15 +53,26 @@ func TestSelectActions(t *testing.T) {
|
||||
|
||||
createTime, _ := time.Parse("2006-01-02", "2020-12-31")
|
||||
updateTime, _ := time.Parse("2006-01-02", "2021-01-01")
|
||||
completeTime, _ := time.Parse("2006-01-02", "2021-01-05")
|
||||
idToUse := 1
|
||||
estChunks := 5
|
||||
compChunks := 7
|
||||
desc := "Howdy, partner."
|
||||
|
||||
str, mock := getDbMock(t)
|
||||
|
||||
rows := sqlmock.NewRows([]string{"action_id", "action_description", "created_at", "updated_at"}).
|
||||
AddRow(idToUse, desc, createTime, updateTime).
|
||||
AddRow(idToUse+1, desc, createTime, updateTime)
|
||||
mock.ExpectQuery("^SELECT action_id, action_description, created_at, updated_at FROM actions$").WillReturnRows(rows)
|
||||
rows := sqlmock.NewRows([]string{
|
||||
"action_id",
|
||||
"action_description",
|
||||
"estimated_chunks",
|
||||
"completed_chunks",
|
||||
"completed_on",
|
||||
"created_at",
|
||||
"updated_at",
|
||||
"plan_id"}).
|
||||
AddRow(idToUse, desc, estChunks, compChunks, completeTime, createTime, updateTime, idToUse).
|
||||
AddRow(idToUse+1, desc, estChunks, compChunks, completeTime, createTime, updateTime, idToUse)
|
||||
mock.ExpectQuery("^SELECT action_id, action_description, estimated_chunks, completed_chunks, completed_on, created_at, updated_at, plan_id FROM actions$").WillReturnRows(rows)
|
||||
|
||||
// function under test
|
||||
actions, err := str.SelectActions()
|
||||
@@ -72,8 +83,12 @@ func TestSelectActions(t *testing.T) {
|
||||
action := actions[0]
|
||||
assert.EqualValues(idToUse, action.ActionID)
|
||||
assert.Equal(desc, action.ActionDescription)
|
||||
assert.Equal(estChunks, action.EstimatedChunks)
|
||||
assert.Equal(compChunks, action.CompletedChunks)
|
||||
assert.Equal(completeTime, action.CompletedOn)
|
||||
assert.Equal(createTime, action.CreatedAt)
|
||||
assert.Equal(updateTime, action.UpdatedAt)
|
||||
assert.Equal(idToUse, action.PlanID)
|
||||
|
||||
if err := mock.ExpectationsWereMet(); err != nil {
|
||||
t.Errorf("unfulfilled expectations: %s", err)
|
||||
@@ -101,7 +116,7 @@ func TestErrActions(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
str, mock := getDbMock(t)
|
||||
|
||||
mock.ExpectQuery("^SELECT action_id, action_description, created_at, updated_at FROM actions$").WillReturnError(fmt.Errorf("example error"))
|
||||
mock.ExpectQuery("^SELECT action_id, action_description, estimated_chunks, completed_chunks, completed_on, created_at, updated_at, plan_id FROM actions$").WillReturnError(fmt.Errorf("example error"))
|
||||
// function under test
|
||||
actions, err := str.SelectActions()
|
||||
// test results
|
||||
|
||||
Reference in New Issue
Block a user