aboutsummaryrefslogtreecommitdiffstats
path: root/spec/core_storagemanager_spec.lua
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2020-03-11 14:36:56 +0000
committerMatthew Wild <mwild1@gmail.com>2020-03-11 14:36:56 +0000
commit1d5af5f0a385ffbe4c46569d8fd8696c8c989a60 (patch)
tree9793156f4c24fd4c9d53980d012005ec31c84eb4 /spec/core_storagemanager_spec.lua
parent40bb67c03bba8f3a7d1c0fed751c5411fb5f270d (diff)
downloadprosody-1d5af5f0a385ffbe4c46569d8fd8696c8c989a60.tar.gz
prosody-1d5af5f0a385ffbe4c46569d8fd8696c8c989a60.zip
storagemanager: Add tests for map stores
Diffstat (limited to 'spec/core_storagemanager_spec.lua')
-rw-r--r--spec/core_storagemanager_spec.lua38
1 files changed, 38 insertions, 0 deletions
diff --git a/spec/core_storagemanager_spec.lua b/spec/core_storagemanager_spec.lua
index c3534cd5..9ecb0cb4 100644
--- a/spec/core_storagemanager_spec.lua
+++ b/spec/core_storagemanager_spec.lua
@@ -90,6 +90,44 @@ describe("storagemanager", function ()
end);
end);
+ describe("map stores", function ()
+ -- These tests rely on being executed in order, disable any order
+ -- randomization for this block
+ randomize(false);
+
+ local store, kv_store;
+ it("may be opened", function ()
+ store = assert(sm.open(test_host, "test-map", "map"));
+ end);
+
+ it("may be opened as a keyval store", function ()
+ kv_store = assert(sm.open(test_host, "test-map", "keyval"));
+ end);
+
+ it("may set a specific key for a user", function ()
+ assert(store:set("user9999", "foo", "bar"));
+ assert.same(kv_store:get("user9999"), { foo = "bar" });
+ end);
+
+ it("may get a specific key for a user", function ()
+ assert.equal("bar", store:get("user9999", "foo"));
+ end);
+
+ it("may remove data for a user", function ()
+ assert(store:set("user9999", "foo", nil));
+ do
+ local ret, err = store:get("user9999", "foo");
+ assert.is_nil(ret);
+ assert.is_nil(err);
+ end
+ do
+ local ret, err = kv_store:get("user9999");
+ assert.is_nil(ret);
+ assert.is_nil(err);
+ end
+ end);
+ end);
+
describe("archive stores", function ()
randomize(false);