From 3e05739491dd455e6993c6fd50b2c830e794bded Mon Sep 17 00:00:00 2001 From: subnetmarco <88.marco@gmail.com> Date: Wed, 11 Sep 2024 16:00:34 -0400 Subject: [PATCH] tests(helpers): supporting optional Redis password --- spec/helpers/redis_helper.lua | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/spec/helpers/redis_helper.lua b/spec/helpers/redis_helper.lua index 37d03545fa11..2338001379bd 100644 --- a/spec/helpers/redis_helper.lua +++ b/spec/helpers/redis_helper.lua @@ -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