aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/mod_storage_internal.lua1
-rw-r--r--spec/core_storagemanager_spec.lua24
2 files changed, 25 insertions, 0 deletions
diff --git a/plugins/mod_storage_internal.lua b/plugins/mod_storage_internal.lua
index 1f1ad68f..deab7dfd 100644
--- a/plugins/mod_storage_internal.lua
+++ b/plugins/mod_storage_internal.lua
@@ -180,6 +180,7 @@ function archive:find(username, query)
i = i - 1
return list[i]
end
+ query.before, query.after = query.after, query.before;
end
if query.key then
iter = it.filter(function(item)
diff --git a/spec/core_storagemanager_spec.lua b/spec/core_storagemanager_spec.lua
index fc3e0ad4..f1adcd50 100644
--- a/spec/core_storagemanager_spec.lua
+++ b/spec/core_storagemanager_spec.lua
@@ -560,6 +560,30 @@ describe("storagemanager", function ()
end);
+ -- This tests combines the reverse flag with 'before' and 'after' to
+ -- ensure behaviour remains correct
+ it("by id (before and after) in reverse #full_id_range", function ()
+ assert.truthy(archive.caps and archive.caps.full_id_range, "full ID range support")
+ local data, err = archive:find("user", {
+ ["after"] = test_data[1][1];
+ ["before"] = test_data[4][1];
+ reverse = true;
+ });
+ assert.truthy(data, err);
+ local count = 0;
+ for id, item in data do
+ count = count + 1;
+ assert.truthy(id);
+ assert.equal(test_data[4-count][1], id);
+ assert(st.is_stanza(item));
+ assert.equal("test", item.name);
+ assert.equal("urn:example:foo", item.attr.xmlns);
+ assert.equal(2, #item.tags);
+ end
+ assert.equal(2, count);
+ end);
+
+
end);