Changeset

10676:33c7e4920591

storagemanager: Add tests for map stores
author Matthew Wild <mwild1@gmail.com>
date Wed, 11 Mar 2020 14:36:56 +0000
parents 10675:5efd6865486c
children 10677:0054aec3e8c5
files spec/core_storagemanager_spec.lua
diffstat 1 files changed, 38 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/spec/core_storagemanager_spec.lua	Fri Feb 28 21:55:40 2020 +0000
+++ b/spec/core_storagemanager_spec.lua	Wed Mar 11 14:36:56 2020 +0000
@@ -90,6 +90,44 @@
 				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);