Skip to content

Commit

Permalink
tests(helpers): supporting optional Redis password
Browse files Browse the repository at this point in the history
  • Loading branch information
subnetmarco committed Sep 11, 2024
1 parent c937edc commit 3e05739
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions spec/helpers/redis_helper.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,19 @@ local version = require "version"
local DEFAULT_TIMEOUT = 2000


local function connect(host, port)
local function connect(host, port, password)
local redis_client = redis:new()
redis_client:set_timeout(DEFAULT_TIMEOUT)
assert(redis_client:connect(host, port))
if password then
assert(redis_client:auth(password))
end
local red_version = string.match(redis_client:info(), 'redis_version:([%g]+)\r\n')
return redis_client, assert(version(red_version))
end

local function reset_redis(host, port)
local redis_client = connect(host, port)
local function reset_redis(host, port, password)
local redis_client = connect(host, port, password)
redis_client:flushall()
redis_client:close()
end
Expand Down

0 comments on commit 3e05739

Please sign in to comment.