Software /
code /
prosody
Comparison
spec/core_storagemanager_spec.lua @ 11354:10fba62332c5
mod_storage_sql: Implement map-like API for archives
Used by mod_http_file_share, muc moderation, etc.
Tests tweaked because they failed on stanza internals that happen
becasue of re-serialization. Namespaces differ since inheritance is
implicit when building but explicit after parsing.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Mon, 01 Feb 2021 12:47:05 +0100 |
parent | 11353:367e6beaf8ab |
child | 11424:2358299bc928 |
comparison
equal
deleted
inserted
replaced
11353:367e6beaf8ab | 11354:10fba62332c5 |
---|---|
554 assert.falsy(archive:set("mapuser", "no-such-id", test_stanza)); | 554 assert.falsy(archive:set("mapuser", "no-such-id", test_stanza)); |
555 | 555 |
556 local id = archive:append("mapuser", nil, test_stanza, test_time, "contact@example.com"); | 556 local id = archive:append("mapuser", nil, test_stanza, test_time, "contact@example.com"); |
557 do | 557 do |
558 local stanza_roundtrip, when, with = archive:get("mapuser", id); | 558 local stanza_roundtrip, when, with = archive:get("mapuser", id); |
559 assert.same(test_stanza, stanza_roundtrip, "same stanza is returned"); | 559 assert.same(tostring(test_stanza), tostring(stanza_roundtrip), "same stanza is returned"); |
560 assert.equal(test_time, when, "same 'when' is returned"); | 560 assert.equal(test_time, when, "same 'when' is returned"); |
561 assert.equal("contact@example.com", with, "same 'with' is returned"); | 561 assert.equal("contact@example.com", with, "same 'with' is returned"); |
562 end | 562 end |
563 | 563 |
564 local replacement_stanza = st.stanza("test", { xmlns = "urn:example:foo" }) | 564 local replacement_stanza = st.stanza("test", { xmlns = "urn:example:foo" }) |
566 :reset(); | 566 :reset(); |
567 assert(archive:set("mapuser", id, replacement_stanza, test_time+1)); | 567 assert(archive:set("mapuser", id, replacement_stanza, test_time+1)); |
568 | 568 |
569 do | 569 do |
570 local replaced, when, with = archive:get("mapuser", id); | 570 local replaced, when, with = archive:get("mapuser", id); |
571 assert.same(replacement_stanza, replaced, "replaced stanza is returned"); | 571 assert.same(tostring(replacement_stanza), tostring(replaced), "replaced stanza is returned"); |
572 assert.equal(test_time+1, when, "modified 'when' is returned"); | 572 assert.equal(test_time+1, when, "modified 'when' is returned"); |
573 assert.equal("contact@example.com", with, "original 'with' is returned"); | 573 assert.equal("contact@example.com", with, "original 'with' is returned"); |
574 end | 574 end |
575 end); | 575 end); |
576 | 576 |