Software /
code /
prosody
Comparison
spec/core_storagemanager_spec.lua @ 10676:33c7e4920591
storagemanager: Add tests for map stores
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Wed, 11 Mar 2020 14:36:56 +0000 |
parent | 10541:6c6ff4509082 |
child | 10677:0054aec3e8c5 |
comparison
equal
deleted
inserted
replaced
10675:5efd6865486c | 10676:33c7e4920591 |
---|---|
85 it("may remove data for a user", function () | 85 it("may remove data for a user", function () |
86 assert(store:set("user9999", nil)); | 86 assert(store:set("user9999", nil)); |
87 local ret, err = store:get("user9999"); | 87 local ret, err = store:get("user9999"); |
88 assert.is_nil(ret); | 88 assert.is_nil(ret); |
89 assert.is_nil(err); | 89 assert.is_nil(err); |
90 end); | |
91 end); | |
92 | |
93 describe("map stores", function () | |
94 -- These tests rely on being executed in order, disable any order | |
95 -- randomization for this block | |
96 randomize(false); | |
97 | |
98 local store, kv_store; | |
99 it("may be opened", function () | |
100 store = assert(sm.open(test_host, "test-map", "map")); | |
101 end); | |
102 | |
103 it("may be opened as a keyval store", function () | |
104 kv_store = assert(sm.open(test_host, "test-map", "keyval")); | |
105 end); | |
106 | |
107 it("may set a specific key for a user", function () | |
108 assert(store:set("user9999", "foo", "bar")); | |
109 assert.same(kv_store:get("user9999"), { foo = "bar" }); | |
110 end); | |
111 | |
112 it("may get a specific key for a user", function () | |
113 assert.equal("bar", store:get("user9999", "foo")); | |
114 end); | |
115 | |
116 it("may remove data for a user", function () | |
117 assert(store:set("user9999", "foo", nil)); | |
118 do | |
119 local ret, err = store:get("user9999", "foo"); | |
120 assert.is_nil(ret); | |
121 assert.is_nil(err); | |
122 end | |
123 do | |
124 local ret, err = kv_store:get("user9999"); | |
125 assert.is_nil(ret); | |
126 assert.is_nil(err); | |
127 end | |
90 end); | 128 end); |
91 end); | 129 end); |
92 | 130 |
93 describe("archive stores", function () | 131 describe("archive stores", function () |
94 randomize(false); | 132 randomize(false); |