leslie-tsang opened a new issue #6265:
URL: https://github.com/apache/apisix/issues/6265


   ### Issue description
   
   The test case in 
[t/core/utils.t](https://github.com/apache/apisix/blob/ec0fc2ceaf04a20b0bd0ebdaad67296a1d3f621c/t/core/utils.t)
 currently has some code errors, such as
   
   
https://github.com/apache/apisix/blob/ec0fc2ceaf04a20b0bd0ebdaad67296a1d3f621c/t/core/utils.t#L80-L89
   
   The variable `host` is a `nil` when the code is executed here (which may 
never happened)
   
   ## Solution
   Let's do it this way.
   ```patch
                local core = require("apisix.core")
                local resolvers = {"8.8.8.8"}
                core.utils.set_resolver(resolvers)
   -            local ip_info, err = core.utils.dns_parse("github.com")
   +            local domain = "github.com"
   +            local ip_info, err = core.utils.dns_parse(domain)
                if not ip_info then
   -                core.log.error("failed to parse domain: ", host, ", error: 
",err)
   +                core.log.error("failed to parse domain: ", domain, ", 
error: ",err)
                end
                ngx.say(require("toolkit.json").encode(ip_info))
   ```
   
   ### Environment
   
   - apisix version (cmd: `apisix version`):
   - OS (cmd: `uname -a`):
   - OpenResty / Nginx version (cmd: `nginx -V` or `openresty -V`):
   - etcd version, if have (cmd: run `curl 
http://127.0.0.1:9090/v1/server_info` to get the info from server-info API):
   - apisix-dashboard version, if have:
   - the plugin runner version, if the issue is about a plugin runner (cmd: 
depended on the kind of runner):
   - luarocks version, if the issue is about installation (cmd: `luarocks 
--version`):
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to