Diff

spec/core_storagemanager_spec.lua @ 12600:3d3a0c4e2662

Merge 0.12->trunk
author Kim Alvefur <zash@zash.se>
date Fri, 29 Jul 2022 17:10:31 +0200
parent 12589:39ae08180c81
parent 12598:a2624315d30e
child 12956:52fcdfe710ca
line wrap: on
line diff
--- a/spec/core_storagemanager_spec.lua	Wed Jul 27 00:32:04 2022 +0200
+++ b/spec/core_storagemanager_spec.lua	Fri Jul 29 17:10:31 2022 +0200
@@ -575,6 +575,23 @@
 					end
 				end);
 
+				it("the summary api works", function()
+					assert.truthy(archive:delete("summary-user"));
+					local first_sid = archive:append("summary-user", nil, test_stanza, test_time, "contact@example.com");
+					local second_sid = archive:append("summary-user", nil, test_stanza, test_time+1, "contact@example.com");
+					assert.truthy(first_sid and second_sid, "preparations failed")
+					---
+
+					local user_summary, err = archive:summary("summary-user");
+					assert.is_table(user_summary, err);
+					assert.same({ ["contact@example.com"] = 2 }, user_summary.counts, "summary.counts matches");
+					assert.same({ ["contact@example.com"] = test_time }, user_summary.earliest, "summary.earliest matches");
+					assert.same({ ["contact@example.com"] = test_time+1 }, user_summary.latest, "summary.latest matches");
+					if user_summary.body then
+						assert.same({ ["contact@example.com"] = test_stanza:get_child_text("body") }, user_summary.body, "summary.body matches");
+					end
+				end);
+
 			end);
 		end);
 	end