diff options
author | Matthew Wild <mwild1@gmail.com> | 2020-03-11 14:36:56 +0000 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2020-03-11 14:36:56 +0000 |
commit | d56fa1f1c1a325bb86084ab71fdd3a77d6db3a61 (patch) | |
tree | 9793156f4c24fd4c9d53980d012005ec31c84eb4 /spec | |
parent | 62fda5c1f4ea55ead3701bd7054b0ea62f32a9ba (diff) | |
download | prosody-d56fa1f1c1a325bb86084ab71fdd3a77d6db3a61.tar.gz prosody-d56fa1f1c1a325bb86084ab71fdd3a77d6db3a61.zip |
storagemanager: Add tests for map stores
Diffstat (limited to 'spec')
-rw-r--r-- | spec/core_storagemanager_spec.lua | 38 |
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); |