Fix bugs in calculateBalances and handle not found categories
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
@ -95,7 +95,8 @@ func (h Handler) CheckAvailableBalance(ctx context.Context, t *testing.T, budget
|
||||
return
|
||||
}
|
||||
|
||||
assert_equal(t, -115170.56, data.AvailableBalance.GetFloat64(), "available balance")
|
||||
// 2022-01 assert_equal(t, -115170.56, data.AvailableBalance.GetFloat64(), "available balance")
|
||||
assert_equal(t, -110181.600, data.AvailableBalance.GetFloat64(), "available balance")
|
||||
|
||||
categoryTestDataFile, err := os.Open("../testdata/production-export/results/categories-2021-12.json")
|
||||
if err != nil {
|
||||
@ -112,6 +113,7 @@ func (h Handler) CheckAvailableBalance(ctx context.Context, t *testing.T, budget
|
||||
}
|
||||
|
||||
for categoryName, categoryTestData := range categoryTestData {
|
||||
found := false
|
||||
for _, category := range data.Categories {
|
||||
name := category.Group + " : " + category.Name
|
||||
|
||||
@ -119,8 +121,12 @@ func (h Handler) CheckAvailableBalance(ctx context.Context, t *testing.T, budget
|
||||
assert_equal(t, categoryTestData.Available, category.Available.GetFloat64(), "available for "+categoryName)
|
||||
assert_equal(t, categoryTestData.Activity, category.Activity.GetFloat64(), "activity for "+categoryName)
|
||||
assert_equal(t, categoryTestData.Assigned, category.Assigned.GetFloat64(), "assigned for "+categoryName)
|
||||
found = true
|
||||
}
|
||||
fmt.Printf("%s: %f %f\n", category.Name, category.Activity.GetFloat64(), category.Available.GetFloat64())
|
||||
}
|
||||
|
||||
if !found {
|
||||
t.Errorf("category " + categoryName + " was not found in result")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user