From 54abde11c2a489e7b654a4e636121a70e25c48ea Mon Sep 17 00:00:00 2001 From: Akayeshmantha Date: Tue, 9 Jun 2020 16:32:26 +0200 Subject: [PATCH] fix unit test. --- t/plugin/echo.t | 66 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/t/plugin/echo.t b/t/plugin/echo.t index 6f740cb404fb1..eae7f44e7a868 100644 --- a/t/plugin/echo.t +++ b/t/plugin/echo.t @@ -138,3 +138,69 @@ before the body modification hello upstream --- no_error_log [error] --- wait: 0.2 + + +=== TEST 5: update plugin +--- config + location /t { + content_by_lua_block { + local t = require("lib.test_admin").test + local code, body = t('/apisix/admin/routes/1', + ngx.HTTP_PUT, + [[{ + "plugins": { + "echo": { + "before_body": "before the body modification " + } + }, + "upstream": { + "nodes": { + "127.0.0.1:1980": 1 + }, + "type": "roundrobin" + }, + "uri": "/hello" + }]], + [[{ + "node": { + "value": { + "plugins": { + "echo": { + "before_body": "before the body modification " + } + }, + "upstream": { + "nodes": { + "127.0.0.1:1980": 1 + }, + "type": "roundrobin" + }, + "uri": "/hello" + }, + "key": "/apisix/routes/1" + }, + "action": "set" + }]] + ) + + if code >= 300 then + ngx.status = code + end + ngx.say(body) + } + } +--- request +GET /t +--- response_body +passed +--- no_error_log +[error] + +=== TEST 6: access without upstream body change +--- request +GET /hello +--- response_body +before the body modification hello world +--- no_error_log +[error] +--- wait: 0.2