Skip to content

Commit cb83787

Browse files
committed
Add status_reply and error_reply helpers to Lua's global 'redis' table.
1 parent 517897e commit cb83787

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

mockredis/script.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,11 @@ def _call(*call_args):
4747
response = client.call(*call_args)
4848
return self._python_to_lua(response)
4949

50-
lua_globals.redis = {"call": _call}
50+
lua_globals.redis = {"call": _call,
51+
# TODO wrap _call with try to implement "pcall": _pcall,
52+
"status_reply": lambda status: self._python_to_lua({"ok": status}),
53+
"error_reply": lambda error: self._python_to_lua({"err": error})
54+
}
5155
return self._lua_to_python(lua.execute(self.script), return_status=True)
5256

5357
@staticmethod

0 commit comments

Comments
 (0)