feat: add durable Kuknos settlement coordination
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
package postgres
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestReconcileConfirmationEvidenceCommitsDurableIssueStats(t *testing.T) {
|
||||
tx := &fakeTx{rows: []Row{
|
||||
fakeRow{values: []any{int64(1)}},
|
||||
fakeRow{values: []any{int64(2)}},
|
||||
}}
|
||||
repository := NewSettlementRepository(&fakeDatabase{tx: tx})
|
||||
|
||||
stats, err := repository.ReconcileConfirmationEvidence(context.Background(), 10*time.Minute)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if stats.Detected != 1 || stats.Resolved != 1 || stats.Open != 2 {
|
||||
t.Fatalf("unexpected reconciliation stats: %+v", stats)
|
||||
}
|
||||
if !tx.committed || tx.execCount != 1 {
|
||||
t.Fatalf("unexpected transaction state: %+v", tx)
|
||||
}
|
||||
}
|
||||
|
||||
func TestReconcileConfirmationEvidenceRollsBackResolutionFailure(t *testing.T) {
|
||||
tx := &fakeTx{
|
||||
rows: []Row{fakeRow{values: []any{int64(1)}}},
|
||||
execErrAt: 1,
|
||||
}
|
||||
repository := NewSettlementRepository(&fakeDatabase{tx: tx})
|
||||
|
||||
if _, err := repository.ReconcileConfirmationEvidence(context.Background(), time.Minute); err == nil {
|
||||
t.Fatal("expected resolution error")
|
||||
}
|
||||
if !tx.rolledBack || tx.committed {
|
||||
t.Fatalf("failed reconciliation was not rolled back: %+v", tx)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user