delta.Transaction export field
parent
666965042a
commit
ddc95c9054
|
|
@ -15,7 +15,7 @@ type Delta struct {
|
||||||
Currency Currency
|
Currency Currency
|
||||||
Description string
|
Description string
|
||||||
isSet bool
|
isSet bool
|
||||||
transaction string
|
Transaction string
|
||||||
}
|
}
|
||||||
|
|
||||||
func newDelta(transaction string, d, desc, name string, v float64, c string, isSet bool) Delta {
|
func newDelta(transaction string, d, desc, name string, v float64, c string, isSet bool) Delta {
|
||||||
|
|
@ -26,7 +26,7 @@ func newDelta(transaction string, d, desc, name string, v float64, c string, isS
|
||||||
Currency: Currency(c),
|
Currency: Currency(c),
|
||||||
Description: desc,
|
Description: desc,
|
||||||
isSet: isSet,
|
isSet: isSet,
|
||||||
transaction: transaction,
|
Transaction: transaction,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,8 @@ func TestDelta(t *testing.T) {
|
||||||
d := "2099-08-07"
|
d := "2099-08-07"
|
||||||
delta := newDelta("x", d, "", "name", 34.56, "$", false)
|
delta := newDelta("x", d, "", "name", 34.56, "$", false)
|
||||||
|
|
||||||
if delta.transaction != "x" {
|
if delta.Transaction != "x" {
|
||||||
t.Error(delta.transaction)
|
t.Error(delta.Transaction)
|
||||||
}
|
}
|
||||||
if delta.Date != d {
|
if delta.Date != d {
|
||||||
t.Error(delta.Date)
|
t.Error(delta.Date)
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ func (files Files) Amend(old, now Delta) error {
|
||||||
|
|
||||||
var transaction transaction
|
var transaction transaction
|
||||||
for _, xaction := range xactions {
|
for _, xaction := range xactions {
|
||||||
if xaction.name != old.transaction {
|
if xaction.name != old.Transaction {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
transaction = xaction
|
transaction = xaction
|
||||||
|
|
|
||||||
|
|
@ -146,7 +146,7 @@ func TestFileAmend(t *testing.T) {
|
||||||
} else if deltas, err := files.Deltas(); err != nil {
|
} else if deltas, err := files.Deltas(); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
} else if filtered := deltas.Like(func(d Delta) bool {
|
} else if filtered := deltas.Like(func(d Delta) bool {
|
||||||
c.old.transaction = d.transaction
|
c.old.Transaction = d.Transaction
|
||||||
return d == c.old
|
return d == c.old
|
||||||
}); len(filtered) != 1 {
|
}); len(filtered) != 1 {
|
||||||
t.Fatalf("input %s didnt include old %+v in %+v", c.from, c.old, deltas)
|
t.Fatalf("input %s didnt include old %+v in %+v", c.from, c.old, deltas)
|
||||||
|
|
@ -424,10 +424,10 @@ func TestFileDeltas(t *testing.T) {
|
||||||
if i >= len(deltas) {
|
if i >= len(deltas) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if deltas[i].transaction == "" {
|
if deltas[i].Transaction == "" {
|
||||||
t.Error(deltas[i].transaction)
|
t.Error(deltas[i].Transaction)
|
||||||
}
|
}
|
||||||
deltas[i].transaction = ""
|
deltas[i].Transaction = ""
|
||||||
if want[i] != deltas[i] {
|
if want[i] != deltas[i] {
|
||||||
t.Errorf("[%d] \n\twant=%s, \n\t got=%s", i, want[i].Debug(), deltas[i].Debug())
|
t.Errorf("[%d] \n\twant=%s, \n\t got=%s", i, want[i].Debug(), deltas[i].Debug())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ type Likes []Like
|
||||||
|
|
||||||
func LikeTransaction(delta Delta) Like {
|
func LikeTransaction(delta Delta) Like {
|
||||||
return func(d Delta) bool {
|
return func(d Delta) bool {
|
||||||
return d.transaction == delta.transaction
|
return d.Transaction == delta.Transaction
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue