imjoey commented on a change in pull request #1289:
URL: https://github.com/apache/apisix-dashboard/pull/1289#discussion_r557004791



##########
File path: api/internal/handler/route/route_test.go
##########
@@ -1349,3 +1349,146 @@ func Test_Route_With_Script(t *testing.T) {
        _, err = handler.BatchDelete(ctx)
        assert.Nil(t, err)
 }
+
+func Test_Route_With_Script_Luacode(t *testing.T) {
+       // init
+       err := storage.InitETCDClient(conf.ETCDConfig)
+       assert.Nil(t, err)
+       err = store.InitStores()
+       assert.Nil(t, err)
+
+       handler := &Handler{
+               routeStore:    store.GetStore(store.HubKeyRoute),
+               svcStore:      store.GetStore(store.HubKeyService),
+               upstreamStore: store.GetStore(store.HubKeyUpstream),
+               scriptStore:   store.GetStore(store.HubKeyScript),
+       }
+       assert.NotNil(t, handler)
+
+       // create with script of valid lua syntax
+       ctx := droplet.NewContext()
+       route := &entity.Route{}
+       reqBody := `{
+                 "id": "1",
+                 "uri": "/index.html",
+                 "upstream": {
+                     "type": "roundrobin",
+                     "nodes": [{
+                         "host": "www.a.com",
+                         "port": 80,
+                         "weight": 1
+                     }]
+                 },
+                 "script": "local _M = {} \n function _M.access(api_ctx) \n 
ngx.log(ngx.INFO,\"hit access phase\") \n end \nreturn _M"
+               }`

Review comment:
       @starsz PR renewed. The style will be fine if we only use  `table` to 
indent the JSON defined as a string type. Thanks for advice. 




----------------------------------------------------------------
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]


Reply via email to