Comparison

spec/core_storagemanager_spec.lua @ 10842:5a6ba2f38e2b

mod_storage_internal: Fix keeping old timestamp in archive map API This led to a missing 'when' field on changed items, which would cause a traceack.
author Kim Alvefur <zash@zash.se>
date Fri, 15 May 2020 20:55:22 +0200
parent 10837:f23363380599
child 10927:470602a8b633
comparison
equal deleted inserted replaced
10841:22f783d80eec 10842:5a6ba2f38e2b
443 it("can be treated as a map store", function () 443 it("can be treated as a map store", function ()
444 assert.falsy(archive:get("mapuser", "no-such-id")); 444 assert.falsy(archive:get("mapuser", "no-such-id"));
445 assert.falsy(archive:set("mapuser", "no-such-id", test_stanza)); 445 assert.falsy(archive:set("mapuser", "no-such-id", test_stanza));
446 446
447 local id = archive:append("mapuser", nil, test_stanza, test_time, "contact@example.com"); 447 local id = archive:append("mapuser", nil, test_stanza, test_time, "contact@example.com");
448 assert.same(test_stanza, archive:get("mapuser", id)); 448 do
449 local stanza_roundtrip, when, with = archive:get("mapuser", id);
450 assert.same(test_stanza, stanza_roundtrip, "same stanza is returned");
451 assert.equal(test_time, when, "same 'when' is returned");
452 assert.equal("contact@example.com", with, "same 'with' is returned");
453 end
449 454
450 local replacement_stanza = st.stanza("test", { xmlns = "urn:example:foo" }) 455 local replacement_stanza = st.stanza("test", { xmlns = "urn:example:foo" })
451 :tag("bar"):up() 456 :tag("bar"):up()
452 :reset(); 457 :reset();
453 assert(archive:set("mapuser", id, replacement_stanza)); 458 assert(archive:set("mapuser", id, replacement_stanza, test_time+1));
454 assert.same(replacement_stanza, archive:get("mapuser", id)); 459
460 do
461 local replaced, when, with = archive:get("mapuser", id);
462 assert.same(replacement_stanza, replaced, "replaced stanza is returned");
463 assert.equal(test_time+1, when, "modified 'when' is returned");
464 assert.equal("contact@example.com", with, "original 'with' is returned");
465 end
455 end); 466 end);
456 467
457 end); 468 end);
458 end); 469 end);
459 end 470 end