81 lines
1.7 KiB
Go
81 lines
1.7 KiB
Go
package service
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestMoneyCalculation(t *testing.T) {
|
|
t.Parallel()
|
|
t.Run("should calculate correct oink balance", func(t *testing.T) {
|
|
// t.Parallel()
|
|
//
|
|
// underTest := NewMoneyImpl()
|
|
//
|
|
// // GIVEN
|
|
// timestamp := time.Date(2020, 01, 01, 0, 0, 0, 0, time.UTC)
|
|
//
|
|
// userId := uuid.New()
|
|
//
|
|
// account := types.Account{
|
|
// Id: uuid.New(),
|
|
// UserId: userId,
|
|
//
|
|
// Type: "Bank",
|
|
// Name: "Bank",
|
|
//
|
|
// CurrentBalance: 0,
|
|
// LastTransaction: time.Time{},
|
|
// OinkBalance: 0,
|
|
// }
|
|
//
|
|
// // The PiggyBank is a fictional account. The money it "holds" is actually in the Account
|
|
// piggyBank := types.PiggyBank{
|
|
// Id: uuid.New(),
|
|
// UserId: userId,
|
|
//
|
|
// AccountId: account.Id,
|
|
// Name: "Car",
|
|
//
|
|
// CurrentBalance: 0,
|
|
// }
|
|
//
|
|
// savingsPlan := types.SavingsPlan{
|
|
// Id: uuid.New(),
|
|
// UserId: userId,
|
|
// PiggyBankId: piggyBank.Id,
|
|
//
|
|
// MonthlySaving: 10,
|
|
//
|
|
// ValidFrom: timestamp,
|
|
// }
|
|
//
|
|
// transaction1 := types.Transaction{
|
|
// Id: uuid.New(),
|
|
// UserId: userId,
|
|
//
|
|
// AccountId: account.Id,
|
|
//
|
|
// Value: 20,
|
|
// Timestamp: timestamp,
|
|
// }
|
|
//
|
|
// transaction2 := types.Transaction{
|
|
// Id: uuid.New(),
|
|
// UserId: userId,
|
|
//
|
|
// AccountId: account.Id,
|
|
// PiggyBankId: &piggyBank.Id,
|
|
//
|
|
// Value: -1,
|
|
// Timestamp: timestamp.Add(1 * time.Hour),
|
|
// }
|
|
//
|
|
// // WHEN
|
|
// actual, err := underTest.CalculateAllBalancesInTime(account, piggyBank, savingsPlan, []types.Transaction{transaction1, transaction2})
|
|
//
|
|
// // THEN
|
|
// assert.Nil(t, err)
|
|
// assert.ElementsMatch(t, expected, actual)
|
|
})
|
|
}
|