Firstsawyou commented on a change in pull request #3556:
URL: https://github.com/apache/apisix/pull/3556#discussion_r604781213
##########
File path: t/plugin/proxy-rewrite.t
##########
@@ -1412,10 +1412,58 @@ passed
-=== TEST 48: rewrite HTTP method
+=== TEST 48: rewrite HTTP method (GET to POST)
--- request
GET /hello
--- response_body
-method: POST
++hello world
++--- error_log eval
++qr/changed HTTP method from GET to POST/
++
++
++
++=== TEST 49: set route(rewrite HTTP method)
++--- config
++ location /t {
++ content_by_lua_block {
++ local t = require("lib.test_admin").test
++ local code, body = t('/apisix/admin/routes/1',
++ ngx.HTTP_PATCH,
++ [[{
++ "plugins": {
++ "proxy-rewrite": {
++ "method": "PUT"
++ }
++ },
++ "upstream": {
++ "nodes": {
++ "127.0.0.1:1980": 1
++ },
++ "type": "roundrobin"
++ },
++ "uri": "/hello"
++ }]]
++ )
++
++ if code >= 300 then
++ ngx.status = code
++ end
++ ngx.say(body)
++ }
++ }
++--- request
++GET /t
++--- response_body
Review comment:
Your test case has more `+` symbols, you need to delete them. like this:
```
hello world
--- error_log eval
qr/changed HTTP method from GET to POST/
=== TEST 49: set route(rewrite HTTP method)
--- config
location /t {
content_by_lua_block {
local t = require("lib.test_admin").test
local code, body = t('/apisix/admin/routes/1',
ngx.HTTP_PATCH,
[[{
"plugins": {
"proxy-rewrite": {
"method": "PUT"
}
},
"upstream": {
"nodes": {
"127.0.0.1:1980": 1
},
"type": "roundrobin"
},
"uri": "/hello"
}]]
)
if code >= 300 then
ngx.status = code
end
ngx.say(body)
}
}
--- request
GET /t
--- response_body
```
--
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.
For queries about this service, please contact Infrastructure at:
[email protected]