chore: initial commit of HouseholdBudgetBook (backend, frontend, desktop)
This commit is contained in:
commit
4a5db3f1f9
167 files changed
+21732
No files matched your search
@@ -0,0 +1,47 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestAccountBalancesCTEUsesGroupedEffects(t *testing.T) {
|
||||
sql := accountBalancesCTE()
|
||||
for _, part := range []string{
|
||||
"transaction_effects AS",
|
||||
"account_deltas AS",
|
||||
"GROUP BY account_id",
|
||||
"LEFT JOIN account_deltas",
|
||||
} {
|
||||
if !strings.Contains(sql, part) {
|
||||
t.Fatalf("missing %q: %s", part, sql)
|
||||
}
|
||||
}
|
||||
for _, forbidden := range []string{
|
||||
"WHERE account_id = a.id",
|
||||
"WHERE account_id = ac.id",
|
||||
} {
|
||||
if strings.Contains(sql, forbidden) {
|
||||
t.Fatalf("correlated balance query remains: %q", forbidden)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestNetWorthSQLUsesSingleAccountBalancesCTE(t *testing.T) {
|
||||
sql := netWorthSQL()
|
||||
if got := strings.Count(sql, "transaction_effects AS"); got != 1 {
|
||||
t.Fatalf("account balance CTE count=%d, want 1: %s", got, sql)
|
||||
}
|
||||
for _, part := range []string{
|
||||
"totals AS",
|
||||
"total_assets",
|
||||
"total_debt",
|
||||
"liquid_assets",
|
||||
"liquid_debt",
|
||||
"FROM totals",
|
||||
} {
|
||||
if !strings.Contains(sql, part) {
|
||||
t.Fatalf("missing %q: %s", part, sql)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user