mirror of
https://github.com/aclindsa/moneygo.git
synced 2024-12-26 23:42:29 -05:00
gnucash tests: Check for the presence of more accounts and their trees
This commit is contained in:
parent
b06b409cd5
commit
d65019f55c
@ -74,18 +74,45 @@ func TestImportGnucash(t *testing.T) {
|
|||||||
t.Fatalf("Error importing from Gnucash: %s\n", err)
|
t.Fatalf("Error importing from Gnucash: %s\n", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Next, find the Expenses/Groceries account
|
// Next, find the Expenses/Groceries account and verify it's balance
|
||||||
var groceries *handlers.Account
|
var income, liabilities, expenses, salary, creditcard, groceries *handlers.Account
|
||||||
accounts, err := getAccounts(d.clients[0])
|
accounts, err := getAccounts(d.clients[0])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Error fetching accounts: %s\n", err)
|
t.Fatalf("Error fetching accounts: %s\n", err)
|
||||||
}
|
}
|
||||||
for _, account := range *accounts.Accounts {
|
for i, account := range *accounts.Accounts {
|
||||||
if account.Name == "Groceries" {
|
if account.Name == "Income" && account.Type == handlers.Income && account.ParentAccountId == -1 {
|
||||||
groceries = &account
|
income = &(*accounts.Accounts)[i]
|
||||||
break
|
} else if account.Name == "Liabilities" && account.Type == handlers.Liability && account.ParentAccountId == -1 {
|
||||||
|
liabilities = &(*accounts.Accounts)[i]
|
||||||
|
} else if account.Name == "Expenses" && account.Type == handlers.Expense && account.ParentAccountId == -1 {
|
||||||
|
expenses = &(*accounts.Accounts)[i]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if income == nil {
|
||||||
|
t.Fatalf("Couldn't find 'Income' account")
|
||||||
|
}
|
||||||
|
if liabilities == nil {
|
||||||
|
t.Fatalf("Couldn't find 'Liabilities' account")
|
||||||
|
}
|
||||||
|
if expenses == nil {
|
||||||
|
t.Fatalf("Couldn't find 'Expenses' account")
|
||||||
|
}
|
||||||
|
for i, account := range *accounts.Accounts {
|
||||||
|
if account.Name == "Salary" && account.Type == handlers.Income && account.ParentAccountId == income.AccountId {
|
||||||
|
salary = &(*accounts.Accounts)[i]
|
||||||
|
} else if account.Name == "Credit Card" && account.Type == handlers.Liability && account.ParentAccountId == liabilities.AccountId {
|
||||||
|
creditcard = &(*accounts.Accounts)[i]
|
||||||
|
} else if account.Name == "Groceries" && account.Type == handlers.Expense && account.ParentAccountId == expenses.AccountId {
|
||||||
|
groceries = &(*accounts.Accounts)[i]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if salary == nil {
|
||||||
|
t.Fatalf("Couldn't find 'Income/Salary' account")
|
||||||
|
}
|
||||||
|
if creditcard == nil {
|
||||||
|
t.Fatalf("Couldn't find 'Liabilities/Credit Card' account")
|
||||||
|
}
|
||||||
if groceries == nil {
|
if groceries == nil {
|
||||||
t.Fatalf("Couldn't find 'Expenses/Groceries' account")
|
t.Fatalf("Couldn't find 'Expenses/Groceries' account")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user