Mercurial > prosody-hg
changeset 14012:373d3edf58aa
Merge 13.0->trunk
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Fri, 12 Dec 2025 12:44:16 +0000 |
| parents | 12af0116e12c (current diff) f77911437539 (diff) |
| children | fbfc06c5f3a8 |
| files | |
| diffstat | 3 files changed, 63 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/mod_storage_internal.lua Sun Dec 07 14:46:07 2025 +0100 +++ b/plugins/mod_storage_internal.lua Fri Dec 12 12:44:16 2025 +0000 @@ -173,6 +173,7 @@ return list[i] end + local after_found; if query then if query.reverse then i = #list + 1 @@ -231,12 +232,23 @@ iter = it.filter(function(item) local found_after = found; if item.key == query.after then + after_found = true; found = true end return found_after; end, iter); end if query.before then + local before_key, before_found = query.before; + for idx = 1, #list do + if list[idx].key == before_key then + before_found = true; + break; + end + end + if not before_found then + return nil, "item-not-found"; + end local found = false; iter = it.filter(function(item) if item.key == query.before then @@ -250,8 +262,18 @@ end end + local first_item = iter(); + if first_item == nil and query and query.after and not after_found then + return nil, "item-not-found"; + end + return function() - local item = iter(); + local item; + if first_item then + item, first_item = first_item, nil; + else + item = iter(); + end if item == nil then if list.close then list:close();
--- a/spec/core_storagemanager_spec.lua Sun Dec 07 14:46:07 2025 +0100 +++ b/spec/core_storagemanager_spec.lua Fri Dec 12 12:44:16 2025 +0000 @@ -621,7 +621,44 @@ assert.equal(2, count); end); + it("for non-existent after id returning error", function () + do + local data, err = archive:find("user", { + ["after"] = "non-existent-id"; + }); + assert.is_falsy(data); + assert.is_equal("item-not-found", err); + end + do + local data, err = archive:find("user", { + ["after"] = "non-existent-id"; + ["reverse"] = true; + }); + assert.is_falsy(data); + assert.is_equal("item-not-found", err); + end + end); + + it("for non-existent before id returning error", function () + do + local data, err = archive:find("user", { + ["before"] = "non-existent-id"; + }); + assert.is_falsy(data); + assert.is_equal("item-not-found", err); + end + + do + local data, err = archive:find("user", { + ["before"] = "non-existent-id"; + ["reverse"] = true; + }); + assert.is_falsy(data); + assert.is_equal("item-not-found", err); + end + + end); end); @@ -791,3 +828,4 @@ end); end end); +
--- a/spec/util_roles_spec.lua Sun Dec 07 14:46:07 2025 +0100 +++ b/spec/util_roles_spec.lua Fri Dec 12 12:44:16 2025 +0000 @@ -80,8 +80,8 @@ assert.truthy(grandchild_role:may("inherited-permission")); end); describe("supports ordered inheritance from multiple roles", function () - local parent_role = roles.new(); - local final_role = roles.new({ + local parent_role = roles and roles.new(); + local final_role = roles and roles.new({ -- Yes, the names are getting confusing. -- btw, test_role is inherited through child_role. inherits = { parent_role, child_role };
