Adds additional postgres insert fields for action
Some checks are pending
gitea-deepak/gogmagog/pipeline/head This commit looks good
gitea-deepak/gogmagog/pipeline/pr-master Build queued...

This commit is contained in:
Deepak Mallubhotla 2021-01-09 22:25:14 -06:00
parent dc18440821
commit 2c630aff95
2 changed files with 4 additions and 4 deletions

View File

@ -51,7 +51,7 @@ func (store *postgresStore) InsertAction(action *models.Action) (int, error) {
estimated_chunks, estimated_chunks,
completed_chunks, completed_chunks,
completed_on, completed_on,
plan_id) VALUES (?) RETURNING action_id`, plan_id) VALUES (?, ?, ?, ?, ?) RETURNING action_id`,
) )
tx := store.db.MustBegin() tx := store.db.MustBegin()
var id int var id int

View File

@ -418,7 +418,7 @@ func TestInsertAction(t *testing.T) {
rows := sqlmock.NewRows([]string{"action_id"}).AddRow(8) rows := sqlmock.NewRows([]string{"action_id"}).AddRow(8)
mock.ExpectBegin() mock.ExpectBegin()
mock.ExpectQuery("^INSERT INTO actions \\(action_description, estimated_chunks, completed_chunks, completed_on, plan_id\\) VALUES \\(\\$1\\) RETURNING action_id$"). mock.ExpectQuery("^INSERT INTO actions \\(action_description, estimated_chunks, completed_chunks, completed_on, plan_id\\) VALUES \\(\\$1, \\$2, \\$3, \\$4, \\$5\\) RETURNING action_id$").
WithArgs("testing", 3, 6, completedOn, 5). WithArgs("testing", 3, 6, completedOn, 5).
WillReturnRows(rows) WillReturnRows(rows)
mock.ExpectCommit() mock.ExpectCommit()
@ -449,7 +449,7 @@ func TestInsertActionErr(t *testing.T) {
} }
mock.ExpectBegin() mock.ExpectBegin()
mock.ExpectQuery("^INSERT INTO actions \\(action_description, estimated_chunks, completed_chunks, completed_on, plan_id\\) VALUES \\(\\$1\\) RETURNING action_id$"). mock.ExpectQuery("^INSERT INTO actions \\(action_description, estimated_chunks, completed_chunks, completed_on, plan_id\\) VALUES \\(\\$1, \\$2, \\$3, \\$4, \\$5\\) RETURNING action_id$").
WithArgs("testing", 3, 6, completedOn, 5). WithArgs("testing", 3, 6, completedOn, 5).
WillReturnError(fmt.Errorf("example error")) WillReturnError(fmt.Errorf("example error"))
mock.ExpectRollback() mock.ExpectRollback()
@ -482,7 +482,7 @@ func TestInsertActionCommitErr(t *testing.T) {
rows := sqlmock.NewRows([]string{"plan_id"}).AddRow(idToUse) rows := sqlmock.NewRows([]string{"plan_id"}).AddRow(idToUse)
mock.ExpectBegin() mock.ExpectBegin()
mock.ExpectQuery("^INSERT INTO actions \\(action_description, estimated_chunks, completed_chunks, completed_on, plan_id\\) VALUES \\(\\$1\\) RETURNING action_id$"). mock.ExpectQuery("^INSERT INTO actions \\(action_description, estimated_chunks, completed_chunks, completed_on, plan_id\\) VALUES \\(\\$1, \\$2, \\$3, \\$4, \\$5\\) RETURNING action_id$").
WithArgs("testing", 3, 6, completedOn, 5). WithArgs("testing", 3, 6, completedOn, 5).
WillReturnRows(rows) WillReturnRows(rows)
mock.ExpectCommit().WillReturnError(fmt.Errorf("another error example")) mock.ExpectCommit().WillReturnError(fmt.Errorf("another error example"))