From a6ec7bcc11d216a59213b015c94fea9c82f76185 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Thu, 31 Dec 2020 10:27:50 -0800 Subject: [PATCH] ;check: add tests for all on-demand checks --- hledger/test/check-accounts.test | 14 ++++++++++++++ hledger/test/check-commodities.test | 14 ++++++++++++++ hledger/test/check-ordereddates.test | 17 +++++++++++++++++ hledger/test/check-payees.test | 4 +--- hledger/test/check-uniqueleafnames.test | 16 ++++++++++++++++ 5 files changed, 62 insertions(+), 3 deletions(-) create mode 100644 hledger/test/check-accounts.test create mode 100644 hledger/test/check-commodities.test create mode 100644 hledger/test/check-ordereddates.test create mode 100644 hledger/test/check-uniqueleafnames.test diff --git a/hledger/test/check-accounts.test b/hledger/test/check-accounts.test new file mode 100644 index 000000000..8f84a18fb --- /dev/null +++ b/hledger/test/check-accounts.test @@ -0,0 +1,14 @@ +# check accounts succeeds when all accounts are declared +< +account a +2020-01-01 + (a) 1 +$ hledger -f- check accounts + +# and otherwise fails: +< +2020-01-01 + (a) 1 +$ hledger -f- check accounts +>2 /undeclared account "a"/ +>=1 diff --git a/hledger/test/check-commodities.test b/hledger/test/check-commodities.test new file mode 100644 index 000000000..b20b8154c --- /dev/null +++ b/hledger/test/check-commodities.test @@ -0,0 +1,14 @@ +# check commodities succeeds when all commodities are declared +< +commodity $1. +2020-01-01 + (a) $1 +$ hledger -f- check commodities + +# and otherwise fails +< +2020-01-01 + (a) $1 +$ hledger -f- check commodities +>2 /undeclared commodity "\$"/ +>=1 diff --git a/hledger/test/check-ordereddates.test b/hledger/test/check-ordereddates.test new file mode 100644 index 000000000..fc640af2c --- /dev/null +++ b/hledger/test/check-ordereddates.test @@ -0,0 +1,17 @@ +# check ordereddates succeeds when transaction dates are ordered +< +2020-01-01 +2020-01-01 +2020-01-02 +$ hledger -f- check ordereddates + +# and otherwise fails +< +2020-01-01 +2020-01-02 +2020-01-01 + (a) 1 +$ hledger -f- check ordereddates +> /transaction date is out of order/ +>=1 +# XXX make it >2 diff --git a/hledger/test/check-payees.test b/hledger/test/check-payees.test index 4a4639294..d71ca2e4f 100644 --- a/hledger/test/check-payees.test +++ b/hledger/test/check-payees.test @@ -1,5 +1,3 @@ -# check payees - # check payees succeeds when all payees are declared: < payee foo @@ -7,7 +5,7 @@ payee foo 2020-01-02 foo | some description $ hledger -f - check payees -# and otherwise fails, eg: +# and otherwise fails: < 2020-01-01 foo $ hledger -f - check payees diff --git a/hledger/test/check-uniqueleafnames.test b/hledger/test/check-uniqueleafnames.test new file mode 100644 index 000000000..b1ccef8ce --- /dev/null +++ b/hledger/test/check-uniqueleafnames.test @@ -0,0 +1,16 @@ +# check uniqueleafnames succeeds when all account leaf names are unique +< +2020-01-01 + (a) 1 + (a:aa) 1 +$ hledger -f- check uniqueleafnames + +# and otherwise fails +< +2020-01-01 + (a) 1 + (b:a) 1 +$ hledger -f- check uniqueleafnames +> /a as a, b:a/ +>=1 +# XXX make it >2; improve message