aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/fixtures/immich_index6
-rw-r--r--test/test_data.lua13
2 files changed, 19 insertions, 0 deletions
diff --git a/test/fixtures/immich_index b/test/fixtures/immich_index
new file mode 100644
index 0000000..7a5b837
--- /dev/null
+++ b/test/fixtures/immich_index
@@ -0,0 +1,6 @@
+generated 1790681173
+url http://immich.example.org:2283
+photo 00000000-0000-0000-0000-000000000001|2014|2014-09-29T19:33:56+00:00|Example City, Italy
+photo 00000000-0000-0000-0000-000000000002|2014|2014-09-29T22:42:35+00:00|
+photo 00000000-0000-0000-0000-000000000003|2019||40.123, 9.456
+photo garbage
diff --git a/test/test_data.lua b/test/test_data.lua
index 65f92e1..7b84b3d 100644
--- a/test/test_data.lua
+++ b/test/test_data.lua
@@ -445,4 +445,17 @@ assert(data.breaktimer_parse('running no\n') == nil, 'no generated key: nil')
assert(data.breaktimer_parse('') == nil, 'empty cache: nil')
assert(data.breaktimer_parse(nil) == nil, 'nil cache: nil')
+-- immich_parse: one entry per photo line, place optional, garbage skipped.
+local im = data.immich_parse(read('test/fixtures/immich_index'))
+assert(im and #im == 3, 'immich photo count, got ' .. tostring(im and #im))
+assert(im[1].year == 2014 and im[1].place == 'Example City, Italy', 'immich first photo')
+assert(table.concat(im[1].taken, ' ') == '2014 9 29 19 33', 'immich taken parses')
+assert(im.url == 'http://immich.example.org:2283', 'immich url parses')
+assert(im[2].place == nil, 'empty place: nil, so the card prints --')
+assert(im[3].taken == nil and im[3].place == '40.123, 9.456', 'missing date, coords place')
+assert(data.immich_parse('photo a|2014||\n') == nil, 'no generated key: nil')
+assert(data.immich_parse(nil) == nil, 'nil index: nil')
+local none = data.immich_parse('generated 1\n')
+assert(none and #none == 0, 'no memories today: empty list, not nil')
+
print('test_data: all assertions passed')