Skip to content

Commit

Permalink
fixup! fix(jobsdb): update cache after transaction completes
Browse files Browse the repository at this point in the history
  • Loading branch information
atzoum committed Oct 14, 2022
1 parent 82ed67a commit 1a8bffc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
4 changes: 2 additions & 2 deletions jobsdb/jobsdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ func (r *storeSafeTx) SqlTx() *sql.Tx {

// EmptyStoreSafeTx returns an empty interface usable only for tests
func EmptyStoreSafeTx() StoreSafeTx {
return &storeSafeTx{}
return &storeSafeTx{tx: &Tx{}}
}

// UpdateSafeTx sealed interface
Expand Down Expand Up @@ -197,7 +197,7 @@ func (r *updateSafeTx) SqlTx() *sql.Tx {

// EmptyUpdateSafeTx returns an empty interface usable only for tests
func EmptyUpdateSafeTx() UpdateSafeTx {
return &updateSafeTx{}
return &updateSafeTx{tx: &Tx{}}
}

// HandleInspector is only intended to be used by tests for verifying the handle's internal state
Expand Down
13 changes: 6 additions & 7 deletions processor/processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package processor

import (
"context"
"database/sql"
"encoding/json"
"fmt"
"reflect"
Expand Down Expand Up @@ -973,8 +972,8 @@ var _ = Describe("Processor", func() {
})

// will be used to save failed events to failed keys table
c.mockProcErrorsDB.EXPECT().WithTx(gomock.Any()).Do(func(f func(tx *sql.Tx) error) {
_ = f(nil)
c.mockProcErrorsDB.EXPECT().WithTx(gomock.Any()).Do(func(f func(tx *jobsdb.Tx) error) {
_ = f(&jobsdb.Tx{})
}).Times(1)

// One Store call is expected for all events
Expand Down Expand Up @@ -1105,8 +1104,8 @@ var _ = Describe("Processor", func() {
assertJobStatus(unprocessedJobsList[0], statuses[0], jobsdb.Succeeded.State)
})

c.mockProcErrorsDB.EXPECT().WithTx(gomock.Any()).Do(func(f func(tx *sql.Tx) error) {
_ = f(nil)
c.mockProcErrorsDB.EXPECT().WithTx(gomock.Any()).Do(func(f func(tx *jobsdb.Tx) error) {
_ = f(&jobsdb.Tx{})
}).Return(nil).Times(1)

// One Store call is expected for all events
Expand Down Expand Up @@ -1183,8 +1182,8 @@ var _ = Describe("Processor", func() {
assertJobStatus(unprocessedJobsList[0], statuses[0], jobsdb.Succeeded.State)
})

c.mockProcErrorsDB.EXPECT().WithTx(gomock.Any()).Do(func(f func(tx *sql.Tx) error) {
_ = f(nil)
c.mockProcErrorsDB.EXPECT().WithTx(gomock.Any()).Do(func(f func(tx *jobsdb.Tx) error) {
_ = f(&jobsdb.Tx{})
}).Return(nil).Times(0)

// One Store call is expected for all events
Expand Down

0 comments on commit 1a8bffc

Please sign in to comment.