Fixes Postgres to be postgres style bindvars
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
ad47895597
commit
ba18d011bd
@ -6,7 +6,6 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
type multiStore struct {
|
type multiStore struct {
|
||||||
actions []*models.Action
|
actions []*models.Action
|
||||||
plans []*models.Plan
|
plans []*models.Plan
|
||||||
|
@ -29,7 +29,7 @@ func (store *postgresStore) SelectActions() ([]*models.Action, error) {
|
|||||||
|
|
||||||
func (store *postgresStore) SelectActionByID(id int) (*models.Action, error) {
|
func (store *postgresStore) SelectActionByID(id int) (*models.Action, error) {
|
||||||
action := models.Action{}
|
action := models.Action{}
|
||||||
err := store.db.Get(&action, "SELECT action_id, action_description, estimated_chunks, completed_chunks, completed_on, created_at, updated_at, plan_id FROM actions WHERE action_id = ?", id)
|
err := store.db.Get(&action, store.db.Rebind("SELECT action_id, action_description, estimated_chunks, completed_chunks, completed_on, created_at, updated_at, plan_id FROM actions WHERE action_id = ?"), id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -120,7 +120,7 @@ func TestSelectActionById(t *testing.T) {
|
|||||||
"plan_id"}).
|
"plan_id"}).
|
||||||
AddRow(idToUse, desc, estChunks, compChunks, completeTime, createTime, updateTime, idToUse)
|
AddRow(idToUse, 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 WHERE action_id = \\?").
|
mock.ExpectQuery("^SELECT action_id, action_description, estimated_chunks, completed_chunks, completed_on, created_at, updated_at, plan_id FROM actions WHERE action_id = \\$1").
|
||||||
WithArgs(1).
|
WithArgs(1).
|
||||||
WillReturnRows(rows)
|
WillReturnRows(rows)
|
||||||
|
|
||||||
@ -181,7 +181,7 @@ func TestErrActionByID(t *testing.T) {
|
|||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
str, mock := getDbMock(t)
|
str, mock := getDbMock(t)
|
||||||
|
|
||||||
mock.ExpectQuery("^SELECT action_id, action_description, estimated_chunks, completed_chunks, completed_on, created_at, updated_at, plan_id FROM actions WHERE action_id = \\?").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 WHERE action_id = \\$1").WillReturnError(fmt.Errorf("example error"))
|
||||||
// function under test
|
// function under test
|
||||||
action, err := str.SelectActionByID(1)
|
action, err := str.SelectActionByID(1)
|
||||||
// test results
|
// test results
|
||||||
|
Loading…
x
Reference in New Issue
Block a user