Diff

spec/core_storagemanager_spec.lua @ 10837:f23363380599

mod_storage_internal: Implement key-value API
author Kim Alvefur <zash@zash.se>
date Mon, 11 May 2020 21:56:19 +0200
parent 10836:93019f3edd68
child 10842:5a6ba2f38e2b
line wrap: on
line diff
--- a/spec/core_storagemanager_spec.lua	Mon May 11 21:41:02 2020 +0200
+++ b/spec/core_storagemanager_spec.lua	Mon May 11 21:56:19 2020 +0200
@@ -439,6 +439,21 @@
 					assert.equal(2, count);
 					assert(archive:delete("user-issue1073"));
 				end);
+
+				it("can be treated as a map store", function ()
+					assert.falsy(archive:get("mapuser", "no-such-id"));
+					assert.falsy(archive:set("mapuser", "no-such-id", test_stanza));
+
+					local id = archive:append("mapuser", nil, test_stanza, test_time, "contact@example.com");
+					assert.same(test_stanza, archive:get("mapuser", id));
+
+					local replacement_stanza = st.stanza("test", { xmlns = "urn:example:foo" })
+						:tag("bar"):up()
+						:reset();
+					assert(archive:set("mapuser", id, replacement_stanza));
+					assert.same(replacement_stanza, archive:get("mapuser", id));
+				end);
+
 			end);
 		end);
 	end