summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/cli.t69
1 files changed, 69 insertions, 0 deletions
diff --git a/test/cli.t b/test/cli.t
index 9b3373a..73eefc1 100644
--- a/test/cli.t
+++ b/test/cli.t
@@ -484,3 +484,72 @@ day and readings are untouched:
$ colitur readings 2027 | head -1
2027-01-01 ef-circumcision | Titus 2:11-15 | Luke 2:21
+
+A minimal inline template renders -- table computes and renders in one
+process (2 January 2027 is a Saturday, not a Sunday, so Holy Name Sunday
+falls on the 3rd, not the 2nd, that year):
+
+ $ printf '{{#days}}{{iso}} {{slug}}\n{{/days}}' > /tmp/t.txt
+ $ colitur table --year 2027 --template /tmp/t.txt | head -2
+ 2027-01-01 ef-circumcision
+ 2027-01-02 ef-christmas-1-saturday
+
+render is the same operation under the name the design used:
+
+ $ colitur render --template /tmp/t.txt --year 2027 | head -2
+ 2027-01-01 ef-circumcision
+ 2027-01-02 ef-christmas-1-saturday
+
+Flavour is inferred from the extension and escapes data -- Sts. Peter &
+Paul (29 June) and its vigil are the only two 2035 entries whose English
+name needs LaTeX escaping:
+
+ $ printf '{{#days}}{{name.en}}\n{{/days}}' > /tmp/t.tex
+ $ colitur table --year 2035 --template /tmp/t.tex | grep -c 'Peter \\& Paul'
+ 2
+
+An unknown extension with no --flavour is an error, not a silent fallback:
+
+ $ printf 'x' > /tmp/t.wat
+ $ colitur table --year 2027 --template /tmp/t.wat
+ colitur: cannot infer a flavour from ".wat"; pass --flavour latex|groff|html|xml|ics|none
+ [2]
+
+ $ colitur table --year 2027 --template /tmp/t.wat --flavour none
+ x
+
+An unrecognised --flavour value is also an error naming the six valid ones:
+
+ $ colitur table --year 2027 --template /tmp/t.txt --flavour bogus
+ colitur: unknown flavour "bogus" (want latex, groff, html, xml, ics or none)
+ [2]
+
+A malformed template is a clear error, not a crash:
+
+ $ printf '{{#days}}oops' > /tmp/bad.txt
+ $ colitur table --year 2027 --template /tmp/bad.txt
+ colitur: template /tmp/bad.txt: unclosed section {{#days}}
+ [2]
+
+A missing template file is an error:
+
+ $ colitur table --year 2027 --template /tmp/nope.txt
+ colitur: cannot read template /tmp/nope.txt
+ [2]
+
+table and render both require --year and --template:
+
+ $ colitur table --year 2027
+ colitur: table requires --year YEAR and --template FILE
+ [2]
+
+ $ colitur render --template /tmp/t.txt
+ colitur: render requires --year YEAR and --template FILE
+ [2]
+
+table/render's own flags have no effect on the other commands, refused
+rather than silently ignored:
+
+ $ colitur emit --format csv --from 2027 --to 2027 --year 2028
+ colitur: --year/--template/--flavour have no effect on `emit`; refusing rather than ignoring them
+ [2]