Software /
code /
prosody
Comparison
spec/core_storagemanager_spec.lua @ 10680:19692fc5c106
storagemanager, mod_storage_sql: Rename methods to :get_all() and :delete_all()
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Wed, 11 Mar 2020 16:32:41 +0000 |
parent | 10679:b50b1eae711c |
child | 10836:93019f3edd68 |
comparison
equal
deleted
inserted
replaced
10679:b50b1eae711c | 10680:19692fc5c106 |
---|---|
112 it("may get a specific key for a user", function () | 112 it("may get a specific key for a user", function () |
113 assert.equal("bar", store:get("user9999", "foo")); | 113 assert.equal("bar", store:get("user9999", "foo")); |
114 end); | 114 end); |
115 | 115 |
116 it("may find all users with a specific key", function () | 116 it("may find all users with a specific key", function () |
117 assert.is_function(store.find_key); | 117 assert.is_function(store.get_all); |
118 assert(store:set("user9999b", "bar", "bar")); | 118 assert(store:set("user9999b", "bar", "bar")); |
119 assert(store:set("user9999c", "foo", "blah")); | 119 assert(store:set("user9999c", "foo", "blah")); |
120 local ret, err = store:find_key("foo"); | 120 local ret, err = store:get_all("foo"); |
121 assert.is_nil(err); | 121 assert.is_nil(err); |
122 assert.same({ user9999 = "bar", user9999c = "blah" }, ret); | 122 assert.same({ user9999 = "bar", user9999c = "blah" }, ret); |
123 end); | 123 end); |
124 | 124 |
125 it("rejects empty or non-string keys to find_key", function () | 125 it("rejects empty or non-string keys to get_all", function () |
126 assert.is_function(store.find_key); | 126 assert.is_function(store.get_all); |
127 do | 127 do |
128 local ret, err = store:find_key(""); | 128 local ret, err = store:get_all(""); |
129 assert.is_nil(ret); | 129 assert.is_nil(ret); |
130 assert.is_not_nil(err); | 130 assert.is_not_nil(err); |
131 end | 131 end |
132 do | 132 do |
133 local ret, err = store:find_key(true); | 133 local ret, err = store:get_all(true); |
134 assert.is_nil(ret); | 134 assert.is_nil(ret); |
135 assert.is_not_nil(err); | 135 assert.is_not_nil(err); |
136 end | 136 end |
137 end); | 137 end); |
138 | 138 |
139 it("rejects empty or non-string keys to delete_key", function () | 139 it("rejects empty or non-string keys to delete_all", function () |
140 assert.is_function(store.delete_key); | 140 assert.is_function(store.delete_all); |
141 do | 141 do |
142 local ret, err = store:delete_key(""); | 142 local ret, err = store:delete_all(""); |
143 assert.is_nil(ret); | 143 assert.is_nil(ret); |
144 assert.is_not_nil(err); | 144 assert.is_not_nil(err); |
145 end | 145 end |
146 do | 146 do |
147 local ret, err = store:delete_key(true); | 147 local ret, err = store:delete_all(true); |
148 assert.is_nil(ret); | 148 assert.is_nil(ret); |
149 assert.is_not_nil(err); | 149 assert.is_not_nil(err); |
150 end | 150 end |
151 end); | 151 end); |
152 | 152 |
153 it("may delete all instances of a specific key", function () | 153 it("may delete all instances of a specific key", function () |
154 assert.is_function(store.delete_key); | 154 assert.is_function(store.delete_all); |
155 assert(store:set("user9999b", "foo", "hello")); | 155 assert(store:set("user9999b", "foo", "hello")); |
156 | 156 |
157 assert(store:delete_key("bar")); | 157 assert(store:delete_all("bar")); |
158 -- Ensure key was deleted | 158 -- Ensure key was deleted |
159 do | 159 do |
160 local ret, err = store:get("user9999b", "bar"); | 160 local ret, err = store:get("user9999b", "bar"); |
161 assert.is_nil(ret); | 161 assert.is_nil(ret); |
162 assert.is_nil(err); | 162 assert.is_nil(err); |