Comparison

spec/core_storagemanager_spec.lua @ 12598:a2624315d30e 0.12

storage tests: Add test for the archive:summary API Passes with memory, internal, sqlite Fails with postgres as in #1766
author Kim Alvefur <zash@zash.se>
date Fri, 22 Jul 2022 18:32:45 +0200
parent 11739:e0d0680e04cc
child 12600:3d3a0c4e2662
comparison
equal deleted inserted replaced
12597:ba05f7e5f2a2 12598:a2624315d30e
573 assert.equal(test_time+1, when, "modified 'when' is returned"); 573 assert.equal(test_time+1, when, "modified 'when' is returned");
574 assert.equal("contact@example.com", with, "original 'with' is returned"); 574 assert.equal("contact@example.com", with, "original 'with' is returned");
575 end 575 end
576 end); 576 end);
577 577
578 it("the summary api works", function()
579 assert.truthy(archive:delete("summary-user"));
580 local first_sid = archive:append("summary-user", nil, test_stanza, test_time, "contact@example.com");
581 local second_sid = archive:append("summary-user", nil, test_stanza, test_time+1, "contact@example.com");
582 assert.truthy(first_sid and second_sid, "preparations failed")
583 ---
584
585 local user_summary, err = archive:summary("summary-user");
586 assert.is_table(user_summary, err);
587 assert.same({ ["contact@example.com"] = 2 }, user_summary.counts, "summary.counts matches");
588 assert.same({ ["contact@example.com"] = test_time }, user_summary.earliest, "summary.earliest matches");
589 assert.same({ ["contact@example.com"] = test_time+1 }, user_summary.latest, "summary.latest matches");
590 if user_summary.body then
591 assert.same({ ["contact@example.com"] = test_stanza:get_child_text("body") }, user_summary.body, "summary.body matches");
592 end
593 end);
594
578 end); 595 end);
579 end); 596 end);
580 end 597 end
581 end); 598 end);