prediction mvp woo

This commit is contained in:
bel
2023-10-27 07:43:01 -06:00
parent 8b6c62cc23
commit 5c26410b0f
2 changed files with 19 additions and 2 deletions

View File

@@ -23,7 +23,7 @@ func (prediction Prediction) predict(latest ledger.Balances, from time.Time, the
for i := range these { for i := range these {
k := these[i].Format("2006-01") k := these[i].Format("2006-01")
result[k] = make(ledger.Balances) result[k] = make(ledger.Balances)
for k2, v2 := range result[k] { for k2, v2 := range latest {
result[k][k2] = maps.Clone(v2) result[k][k2] = maps.Clone(v2)
} }

View File

@@ -44,7 +44,24 @@ func TestPredictionPredict(t *testing.T) {
want: ledger.Register{theseK: {}}, want: ledger.Register{theseK: {}},
}, },
"double": { "double": {
prediction: {double}, prediction: Prediction{double},
given: ledger.Balances{"X": ledger.Balance{"X": 2}},
want: ledger.Register{theseK: ledger.Balances{"X": ledger.Balance{"X": 4}}},
},
"inc": {
prediction: Prediction{inc},
given: ledger.Balances{"X": ledger.Balance{"X": 2}},
want: ledger.Register{theseK: ledger.Balances{"X": ledger.Balance{"X": 3}}},
},
"inc, double": {
prediction: Prediction{inc, double},
given: ledger.Balances{"X": ledger.Balance{"X": 5}},
want: ledger.Register{theseK: ledger.Balances{"X": ledger.Balance{"X": 12}}},
},
"double, inc": {
prediction: Prediction{double, inc},
given: ledger.Balances{"X": ledger.Balance{"X": 5}},
want: ledger.Register{theseK: ledger.Balances{"X": ledger.Balance{"X": 11}}},
}, },
} }