Skip to content

Commit

Permalink
fake: save and expose last transaction executed with Run().
Browse files Browse the repository at this point in the history
Signed-off-by: Nadia Pinaeva <[email protected]>
  • Loading branch information
npinaeva committed Jul 19, 2024
1 parent c2bd3a9 commit 64bce66
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions fake.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ type Fake struct {
// Table contains the Interface's table. This will be `nil` until you `tx.Add()`
// the table.
Table *FakeTable

// LastTransaction is the last transaction passed to Run(). It will remain set until the
// next time Run() is called. (It is not affected by Check().)
LastTransaction *Transaction
}

// FakeTable wraps Table for the Fake implementation
Expand Down Expand Up @@ -165,6 +169,7 @@ func (fake *Fake) NewTransaction() *Transaction {

// Run is part of Interface
func (fake *Fake) Run(_ context.Context, tx *Transaction) error {
fake.LastTransaction = tx
updatedTable, err := fake.run(tx)
if err == nil {
fake.Table = updatedTable
Expand Down

0 comments on commit 64bce66

Please sign in to comment.