39 lines
1.0 KiB
Go
39 lines
1.0 KiB
Go
package main
|
|
|
|
import "testing"
|
|
|
|
func TestLedgerTransactions(t *testing.T) {
|
|
ledger, err := NewLedger("./testdata/ledger.dat")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
transactions, err := ledger.Transactions()
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if len(transactions) != 2 {
|
|
t.Fatal(transactions)
|
|
}
|
|
if want := (Transaction{
|
|
Date: "2021-07-29",
|
|
Description: "Qt needs pizza n kodiak",
|
|
Payee: "Withdrawal:Home:Grocery+Resturaunt:Target",
|
|
Payer: "Debts:Credit:ChaseAarpChaseVisa",
|
|
Amount: 37.86,
|
|
}); transactions[0] != want {
|
|
t.Fatalf("want \n\t%+v, got \n\t%+v", want, transactions[0])
|
|
}
|
|
if want := (Transaction{
|
|
Date: "2021-07-30",
|
|
Description: "Testing detecting deposits via email alerts 5421705162",
|
|
Payer: "AssetAccount:Cash:Uccu",
|
|
Payee: "Debts:Credit:ChaseAarpChaseVisa",
|
|
Amount: 100.00,
|
|
}); transactions[1] != want {
|
|
t.Fatalf("want \n\t%+v, got \n\t%+v", want, transactions[1])
|
|
}
|
|
for i := range transactions {
|
|
t.Logf("%+v => \n%s", transactions[i], transactions[i].Marshal())
|
|
}
|
|
}
|