Adds additional postgres insert fields for action
This commit is contained in:
parent
dc18440821
commit
2c630aff95
@ -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
|
||||||
|
@ -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"))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user