From 2c630aff95a2d79455771d1dd4f75a2fe930ccc4 Mon Sep 17 00:00:00 2001 From: Deepak Date: Sat, 9 Jan 2021 22:25:14 -0600 Subject: [PATCH] Adds additional postgres insert fields for action --- store/postgres.go | 2 +- store/postgres_test.go | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/store/postgres.go b/store/postgres.go index 5b9cb06..ae041de 100644 --- a/store/postgres.go +++ b/store/postgres.go @@ -51,7 +51,7 @@ func (store *postgresStore) InsertAction(action *models.Action) (int, error) { estimated_chunks, completed_chunks, completed_on, - plan_id) VALUES (?) RETURNING action_id`, + plan_id) VALUES (?, ?, ?, ?, ?) RETURNING action_id`, ) tx := store.db.MustBegin() var id int diff --git a/store/postgres_test.go b/store/postgres_test.go index 799dfc2..823beb6 100644 --- a/store/postgres_test.go +++ b/store/postgres_test.go @@ -418,7 +418,7 @@ func TestInsertAction(t *testing.T) { rows := sqlmock.NewRows([]string{"action_id"}).AddRow(8) 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). WillReturnRows(rows) mock.ExpectCommit() @@ -449,7 +449,7 @@ func TestInsertActionErr(t *testing.T) { } 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). WillReturnError(fmt.Errorf("example error")) mock.ExpectRollback() @@ -482,7 +482,7 @@ func TestInsertActionCommitErr(t *testing.T) { rows := sqlmock.NewRows([]string{"plan_id"}).AddRow(idToUse) 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). WillReturnRows(rows) mock.ExpectCommit().WillReturnError(fmt.Errorf("another error example"))