From 64bce66e42542dc383e6c6684e5dbadb3dc35a85 Mon Sep 17 00:00:00 2001 From: Nadia Pinaeva Date: Thu, 18 Jul 2024 09:17:35 +0200 Subject: [PATCH] fake: save and expose last transaction executed with Run(). Signed-off-by: Nadia Pinaeva --- fake.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fake.go b/fake.go index 1be40e6..584c27a 100644 --- a/fake.go +++ b/fake.go @@ -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 @@ -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