From 9b00bc8db1cc202ae95e7433b6763c50418701c0 Mon Sep 17 00:00:00 2001 From: Aaron Lindsay Date: Mon, 23 Oct 2017 20:10:00 -0400 Subject: [PATCH] testing: Add more data --- internal/handlers/accounts_test.go | 7 ++++- internal/handlers/testdata_test.go | 43 ++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/internal/handlers/accounts_test.go b/internal/handlers/accounts_test.go index 0c0bc70..befbe56 100644 --- a/internal/handlers/accounts_test.go +++ b/internal/handlers/accounts_test.go @@ -138,7 +138,12 @@ func TestUpdateAccount(t *testing.T) { curr.Name = "blah" curr.Type = handlers.Payable - curr.SecurityId = d.securities[1].SecurityId + for _, s := range d.securities { + if s.UserId == curr.UserId { + curr.SecurityId = s.SecurityId + break + } + } a, err := updateAccount(d.clients[orig.UserId], &curr) if err != nil { diff --git a/internal/handlers/testdata_test.go b/internal/handlers/testdata_test.go index db420bb..4090735 100644 --- a/internal/handlers/testdata_test.go +++ b/internal/handlers/testdata_test.go @@ -61,6 +61,7 @@ func (t *TestData) initUser(user *User, userid int) error { if err != nil { return err } + t.clients = append(t.clients, client) // TODO initialize everything else owned by this user in the TestData struct @@ -170,6 +171,15 @@ var data = []TestData{ Type: handlers.Stock, AlternateId: "78462F103", }, + handlers.Security{ + UserId: 1, + Name: "EUR", + Description: "Euro", + Symbol: "€", + Precision: 2, + Type: handlers.Currency, + AlternateId: "978", + }, }, accounts: []handlers.Account{ handlers.Account{ @@ -207,6 +217,20 @@ var data = []TestData{ Type: handlers.Expense, Name: "Cable", }, + handlers.Account{ + UserId: 1, + SecurityId: 2, + ParentAccountId: -1, + Type: handlers.Asset, + Name: "Assets", + }, + handlers.Account{ + UserId: 1, + SecurityId: 2, + ParentAccountId: -1, + Type: handlers.Expense, + Name: "Expenses", + }, }, transactions: []handlers.Transaction{ handlers.Transaction{ @@ -247,6 +271,25 @@ var data = []TestData{ }, }, }, + handlers.Transaction{ + UserId: 1, + Description: "Gas", + Date: time.Date(2017, time.November, 1, 13, 19, 50, 0, time.UTC), + Splits: []*handlers.Split{ + &handlers.Split{ + Status: handlers.Reconciled, + AccountId: 5, + SecurityId: -1, + Amount: "-24.56", + }, + &handlers.Split{ + Status: handlers.Entered, + AccountId: 6, + SecurityId: -1, + Amount: "24.56", + }, + }, + }, }, }, }