From 0aa8ac63abe7d06b6074ccc35c3cdf427d6339be Mon Sep 17 00:00:00 2001 From: Aaron Lindsay Date: Wed, 22 Nov 2017 21:37:45 -0500 Subject: [PATCH] testing: Test importing Gnucash security prices --- internal/handlers/gnucash_test.go | 32 ++++++++++++++++++ .../handlers_testdata/example.gnucash | Bin 4858 -> 5199 bytes 2 files changed, 32 insertions(+) diff --git a/internal/handlers/gnucash_test.go b/internal/handlers/gnucash_test.go index 264aff7..5efd41e 100644 --- a/internal/handlers/gnucash_test.go +++ b/internal/handlers/gnucash_test.go @@ -149,5 +149,37 @@ func TestImportGnucash(t *testing.T) { gnucashAccountBalanceHelper(t, d.clients[0], openingbalances, "-21014.33") gnucashAccountBalanceHelper(t, d.clients[0], groceries, "287.56") // 87.19 from preexisting transactions and 200.37 from Gnucash gnucashAccountBalanceHelper(t, d.clients[0], cable, "89.98") + + var ge *handlers.Security + securities, err := getSecurities(d.clients[0]) + if err != nil { + t.Fatalf("Error fetching securities: %s\n", err) + } + for i, security := range *securities.Securities { + if security.Symbol == "GE" { + ge = (*securities.Securities)[i] + } + } + if ge == nil { + t.Fatalf("Couldn't find GE security") + } + + prices, err := getPrices(d.clients[0], ge.SecurityId) + if err != nil { + t.Fatalf("Error fetching prices: %s\n", err) + } + var p1787, p2894, p3170 bool + for _, price := range *prices.Prices { + if price.CurrencyId == d.securities[0].SecurityId && price.Value == "17.87" { + p1787 = true + } else if price.CurrencyId == d.securities[0].SecurityId && price.Value == "28.94" { + p2894 = true + } else if price.CurrencyId == d.securities[0].SecurityId && price.Value == "31.70" { + p3170 = true + } + } + if !p1787 || !p2894 || !p3170 { + t.Errorf("Error finding expected prices\n") + } }) } diff --git a/internal/handlers/handlers_testdata/example.gnucash b/internal/handlers/handlers_testdata/example.gnucash index f6097e1d35e598d8ece340d585561f8b97b776a1..e3a6ef2110eb416f24388b0d8034adcc6c12de2d 100644 GIT binary patch literal 5199 zcmV-V6tL?biwFP!000001MOXFbK6F;{hnXJ>+cHZ{Z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