Check available balance

This commit is contained in:
2022-04-05 16:22:20 +00:00
parent 2d9c380cf4
commit 2feefea737
2 changed files with 50 additions and 19 deletions

View File

@ -8,6 +8,7 @@ import (
"net/http"
"os"
"testing"
"time"
"git.javil.eu/jacob1123/budgeteer/bcrypt"
"git.javil.eu/jacob1123/budgeteer/config"
@ -68,8 +69,7 @@ func TestMain(t *testing.T) {
handler.DoYNABImport(ctx, t, budget)
// import from YNAB
handler.CheckAvailableBalance(ctx, t, budget)
// check available balance
// check categories
@ -77,6 +77,24 @@ func TestMain(t *testing.T) {
// check accounts
}
func (h Handler) CheckAvailableBalance(ctx context.Context, t *testing.T, budget *postgres.Budget) {
loc := time.Now().Location()
first := time.Date(2022, 1, 1, 0, 0, 0, 0, loc)
firstOfNextMonth := time.Date(2022, 2, 1, 0, 0, 0, 0, loc)
data, err := h.prepareBudgeting(ctx, *budget, firstOfNextMonth, first)
if err != nil {
fmt.Println(err)
t.Fail()
return
}
if data.AvailableBalance.GetFloat64() != -115170.56 {
fmt.Println("Available balance is wrong:")
t.Fail()
return
}
}
func (h Handler) DoYNABImport(ctx context.Context, t *testing.T, budget *postgres.Budget) {
t.Helper()
budgetID := budget.ID