This is an automated email from the ASF dual-hosted git repository.
spacewander pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git
The following commit(s) were added to refs/heads/master by this push:
new bdf71aea4 fix: error handling in core.etcd.server_version (#7367)
bdf71aea4 is described below
commit bdf71aea441c88287a1149063ad0e9221bd22efd
Author: 罗泽轩 <[email protected]>
AuthorDate: Mon Jul 4 13:57:46 2022 +0800
fix: error handling in core.etcd.server_version (#7367)
Signed-off-by: spacewander <[email protected]>
---
apisix/core/etcd.lua | 2 +-
t/core/etcd.t | 20 ++++++++++++++++++++
2 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/apisix/core/etcd.lua b/apisix/core/etcd.lua
index 48ea41a95..caa648569 100644
--- a/apisix/core/etcd.lua
+++ b/apisix/core/etcd.lua
@@ -413,7 +413,7 @@ end
-- -- etcdserver = "3.5.0"
-- -- }
function _M.server_version()
- local etcd_cli, err = new()
+ local etcd_cli, _, err = new()
if not etcd_cli then
return nil, err
end
diff --git a/t/core/etcd.t b/t/core/etcd.t
index 8d1bdc958..1b8f25db4 100644
--- a/t/core/etcd.t
+++ b/t/core/etcd.t
@@ -415,3 +415,23 @@ qr/init_by_lua:\d+: \S+/
init_by_lua:12: ab
init_by_lua:19: 200
init_by_lua:26: 404
+
+
+
+=== TEST 8: error handling in server_version
+--- config
+ location /t {
+ content_by_lua_block {
+ local etcd_lib = require("resty.etcd")
+ etcd_lib.new = function()
+ return nil, "ouch"
+ end
+ local etcd = require("apisix.core.etcd")
+ local res, err = etcd.server_version()
+ ngx.say(err)
+ }
+ }
+--- request
+GET /t
+--- response_body
+ouch