Skip to content

Commit

Permalink
01-unit/01-db/11-declarative_lmdb_spec.lua
Browse files Browse the repository at this point in the history
  • Loading branch information
chronolaw committed Sep 24, 2024
1 parent b11e659 commit 3e46e4c
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions spec/01-unit/01-db/11-declarative_lmdb_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,13 @@ describe("#off preserve nulls", function()
assert(declarative.load_into_cache(entities, meta, current_hash))

local id, item = next(entities.basicauth_credentials)

-- format changed after incremental sync
local cache_key = concat({
"basicauth_credentials:",
id,
":::::",
item.ws_id
"basicauth_credentials|",
item.ws_id,
"|*|",
id
})

local lmdb = require "resty.lmdb"
Expand All @@ -222,17 +224,23 @@ describe("#off preserve nulls", function()

for _, plugin in pairs(entities.plugins) do
if plugin.name == PLUGIN_NAME then

-- format changed after incremental sync
cache_key = concat({
"plugins:" .. PLUGIN_NAME .. ":",
"plugins|",
plugin.ws_id,
"|route|",
plugin.route.id,
"::::",
plugin.ws_id
"|",
plugin.id
})
value, err, hit_lvl = lmdb.get(cache_key)
assert.is_nil(err)
assert.are_equal(hit_lvl, 1)

cached_item = buffer.decode(value)
-- get value by the index key
cached_item = buffer.decode(lmdb.get(value))

assert.are_same(cached_item, plugin)
assert.are_equal(cached_item.config.large, null)
assert.are_equal(cached_item.config.ttl, null)
Expand Down

0 comments on commit 3e46e4c

Please sign in to comment.