starsz commented on a change in pull request #1673:
URL: https://github.com/apache/apisix-dashboard/pull/1673#discussion_r602820979



##########
File path: web/cypress/fixtures/export-route-dataset.json
##########
@@ -131,7 +129,6 @@
             }
           },
           "x-apisix-enable_websocket": false,
-          "x-apisix-plugins": {},

Review comment:
       Just want to know why delete it?

##########
File path: api/test/e2e/route_export_test.go
##########
@@ -2505,6 +2503,499 @@ func TestRoute_Export_Equal_URI(t *testing.T) {
 
 }
 
+func TestRoute_Export_Methods_Feild_Empty(t *testing.T) {
+       exportStr := `{
+               "components": {},
+               "info": {
+                       "title": "RoutesExport",
+                       "version": "3.0.0"
+               },
+               "openapi": "3.0.0",
+               "paths": {
+                       "/test-test": {
+                               "connect": {
+                                       "operationId": "route_allCONNECT",
+                                       "requestBody": {},
+                                       "responses": {
+                                               "default": {
+                                                       "description": ""
+                                               }
+                                       },
+                                       "summary": "所有",
+                                       "x-apisix-enable_websocket": false,
+                                       "x-apisix-hosts": ["test.com"],
+                                       "x-apisix-priority": 0,
+                                       "x-apisix-status": 1,
+                                       "x-apisix-upstream": {
+                                               "nodes": {
+                                                       "172.16.238.20:1980": 1
+                                               },
+                                               "type": "roundrobin"
+                                       }
+                               },
+                               "delete": {
+                                       "operationId": "route_allDELETE",
+                                       "requestBody": {},
+                                       "responses": {
+                                               "default": {
+                                                       "description": ""
+                                               }
+                                       },
+                                       "summary": "所有",
+                                       "x-apisix-enable_websocket": false,
+                                       "x-apisix-hosts": ["test.com"],
+                                       "x-apisix-priority": 0,
+                                       "x-apisix-status": 1,
+                                       "x-apisix-upstream": {
+                                               "nodes": {
+                                                       "172.16.238.20:1980": 1
+                                               },
+                                               "type": "roundrobin"
+                                       }
+                               },
+                               "get": {
+                                       "operationId": "route_allGET",
+                                       "requestBody": {},
+                                       "responses": {
+                                               "default": {
+                                                       "description": ""
+                                               }
+                                       },
+                                       "summary": "所有",
+                                       "x-apisix-enable_websocket": false,
+                                       "x-apisix-hosts": ["test.com"],
+                                       "x-apisix-priority": 0,
+                                       "x-apisix-status": 1,
+                                       "x-apisix-upstream": {
+                                               "nodes": {
+                                                       "172.16.238.20:1980": 1
+                                               },
+                                               "type": "roundrobin"
+                                       }
+                               },
+                               "head": {
+                                       "operationId": "route_allHEAD",
+                                       "requestBody": {},
+                                       "responses": {
+                                               "default": {
+                                                       "description": ""
+                                               }
+                                       },
+                                       "summary": "所有",
+                                       "x-apisix-enable_websocket": false,
+                                       "x-apisix-hosts": ["test.com"],
+                                       "x-apisix-priority": 0,
+                                       "x-apisix-status": 1,
+                                       "x-apisix-upstream": {
+                                               "nodes": {
+                                                       "172.16.238.20:1980": 1
+                                               },
+                                               "type": "roundrobin"
+                                       }
+                               },
+                               "options": {
+                                       "operationId": "route_allOPTIONS",
+                                       "requestBody": {},
+                                       "responses": {
+                                               "default": {
+                                                       "description": ""
+                                               }
+                                       },
+                                       "summary": "所有",
+                                       "x-apisix-enable_websocket": false,
+                                       "x-apisix-hosts": ["test.com"],
+                                       "x-apisix-priority": 0,
+                                       "x-apisix-status": 1,
+                                       "x-apisix-upstream": {
+                                               "nodes": {
+                                                       "172.16.238.20:1980": 1
+                                               },
+                                               "type": "roundrobin"
+                                       }
+                               },
+                               "patch": {
+                                       "operationId": "route_allPATCH",
+                                       "requestBody": {},
+                                       "responses": {
+                                               "default": {
+                                                       "description": ""
+                                               }
+                                       },
+                                       "summary": "所有",
+                                       "x-apisix-enable_websocket": false,
+                                       "x-apisix-hosts": ["test.com"],
+                                       "x-apisix-priority": 0,
+                                       "x-apisix-status": 1,
+                                       "x-apisix-upstream": {
+                                               "nodes": {
+                                                       "172.16.238.20:1980": 1
+                                               },
+                                               "type": "roundrobin"
+                                       }
+                               },
+                               "post": {
+                                       "operationId": "route_allPOST",
+                                       "requestBody": {},
+                                       "responses": {
+                                               "default": {
+                                                       "description": ""
+                                               }
+                                       },
+                                       "summary": "所有",
+                                       "x-apisix-enable_websocket": false,
+                                       "x-apisix-hosts": ["test.com"],
+                                       "x-apisix-priority": 0,
+                                       "x-apisix-status": 1,
+                                       "x-apisix-upstream": {
+                                               "nodes": {
+                                                       "172.16.238.20:1980": 1
+                                               },
+                                               "type": "roundrobin"
+                                       }
+                               },
+                               "put": {
+                                       "operationId": "route_allPUT",
+                                       "requestBody": {},
+                                       "responses": {
+                                               "default": {
+                                                       "description": ""
+                                               }
+                                       },
+                                       "summary": "所有",
+                                       "x-apisix-enable_websocket": false,
+                                       "x-apisix-hosts": ["test.com"],
+                                       "x-apisix-priority": 0,
+                                       "x-apisix-status": 1,
+                                       "x-apisix-upstream": {
+                                               "nodes": {
+                                                       "172.16.238.20:1980": 1
+                                               },
+                                               "type": "roundrobin"
+                                       }
+                               },
+                               "trace": {
+                                       "operationId": "route_allTRACE",
+                                       "requestBody": {},
+                                       "responses": {
+                                               "default": {
+                                                       "description": ""
+                                               }
+                                       },
+                                       "summary": "所有",
+                                       "x-apisix-enable_websocket": false,
+                                       "x-apisix-hosts": ["test.com"],
+                                       "x-apisix-priority": 0,
+                                       "x-apisix-status": 1,
+                                       "x-apisix-upstream": {
+                                               "nodes": {
+                                                       "172.16.238.20:1980": 1
+                                               },
+                                               "type": "roundrobin"
+                                       }
+                               }
+                       }
+               }
+       }`
+       exportStr = replaceStr(exportStr)
+
+       tests := []HttpTestCase{
+               {
+                       Desc:   "Create a route",
+                       Object: ManagerApiExpect(t),
+                       Method: http.MethodPut,
+                       Path:   "/apisix/admin/routes/r1",
+                       Body: `{
+                                       "uris": ["/test-test"],
+                                       "name": "route_all",
+                                       "desc": "所有",
+                                       "methods": [],
+                                       "hosts": ["test.com"],
+                                       "status": 1,
+                                       "upstream": {
+                                               "nodes": {
+                                                       "172.16.238.20:1980": 1
+                                               },
+                                               "type": "roundrobin"
+                                       }
+                       }`,
+                       Headers:      map[string]string{"Authorization": token},
+                       ExpectStatus: http.StatusOK,
+                       Sleep:        sleepTime,
+               },
+               {
+                       Desc:         "export route",
+                       Object:       ManagerApiExpect(t),
+                       Method:       http.MethodGet,
+                       Path:         "/apisix/admin/export/routes/r1",
+                       Headers:      map[string]string{"Authorization": token},
+                       ExpectStatus: http.StatusOK,
+                       ExpectBody:   exportStr,
+               },
+               {
+                       Desc:         "delete the route1 just created",
+                       Object:       ManagerApiExpect(t),
+                       Method:       http.MethodDelete,
+                       Path:         "/apisix/admin/routes/r1",
+                       Headers:      map[string]string{"Authorization": token},
+                       ExpectStatus: http.StatusOK,
+               },
+               {
+                       Desc:         "hit the route just deleted",
+                       Object:       APISIXExpect(t),
+                       Method:       http.MethodGet,
+                       Path:         "/hello",
+                       ExpectStatus: http.StatusNotFound,
+                       ExpectBody:   "{\"error_msg\":\"404 Route Not 
Found\"}\n",
+                       Sleep:        sleepTime,
+               },
+       }
+       for _, tc := range tests {
+               testCaseCheck(tc, t)
+       }
+
+}
+
+func TestRoute_Export_Methods_Feild_Nil(t *testing.T) {
+       exportStr := `{
+               "components": {},
+               "info": {
+                       "title": "RoutesExport",
+                       "version": "3.0.0"
+               },
+               "openapi": "3.0.0",
+               "paths": {
+                       "/test-test": {
+                               "connect": {
+                                       "operationId": "route_allCONNECT",
+                                       "requestBody": {},
+                                       "responses": {
+                                               "default": {
+                                                       "description": ""
+                                               }
+                                       },
+                                       "x-apisix-enable_websocket": false,
+                                       "x-apisix-hosts": ["test.com"],
+                                       "x-apisix-priority": 0,
+                                       "x-apisix-status": 1,
+                                       "x-apisix-upstream": {
+                                               "nodes": {
+                                                       "172.16.238.20:1980": 1
+                                               },
+                                               "type": "roundrobin"
+                                       }
+                               },
+                               "delete": {
+                                       "operationId": "route_allDELETE",
+                                       "requestBody": {},
+                                       "responses": {
+                                               "default": {
+                                                       "description": ""
+                                               }
+                                       },
+                                       "x-apisix-enable_websocket": false,
+                                       "x-apisix-hosts": ["test.com"],
+                                       "x-apisix-priority": 0,
+                                       "x-apisix-status": 1,
+                                       "x-apisix-upstream": {
+                                               "nodes": {
+                                                       "172.16.238.20:1980": 1
+                                               },
+                                               "type": "roundrobin"
+                                       }
+                               },
+                               "get": {
+                                       "operationId": "route_allGET",
+                                       "requestBody": {},
+                                       "responses": {
+                                               "default": {
+                                                       "description": ""
+                                               }
+                                       },
+                                       "x-apisix-enable_websocket": false,
+                                       "x-apisix-hosts": ["test.com"],
+                                       "x-apisix-priority": 0,
+                                       "x-apisix-status": 1,
+                                       "x-apisix-upstream": {
+                                               "nodes": {
+                                                       "172.16.238.20:1980": 1
+                                               },
+                                               "type": "roundrobin"
+                                       }
+                               },
+                               "head": {
+                                       "operationId": "route_allHEAD",
+                                       "requestBody": {},
+                                       "responses": {
+                                               "default": {
+                                                       "description": ""
+                                               }
+                                       },
+                                       "x-apisix-enable_websocket": false,
+                                       "x-apisix-hosts": ["test.com"],
+                                       "x-apisix-priority": 0,
+                                       "x-apisix-status": 1,
+                                       "x-apisix-upstream": {
+                                               "nodes": {
+                                                       "172.16.238.20:1980": 1
+                                               },
+                                               "type": "roundrobin"
+                                       }
+                               },
+                               "options": {
+                                       "operationId": "route_allOPTIONS",
+                                       "requestBody": {},
+                                       "responses": {
+                                               "default": {
+                                                       "description": ""
+                                               }
+                                       },
+                                       "x-apisix-enable_websocket": false,
+                                       "x-apisix-hosts": ["test.com"],
+                                       "x-apisix-priority": 0,
+                                       "x-apisix-status": 1,
+                                       "x-apisix-upstream": {
+                                               "nodes": {
+                                                       "172.16.238.20:1980": 1
+                                               },
+                                               "type": "roundrobin"
+                                       }
+                               },
+                               "patch": {
+                                       "operationId": "route_allPATCH",
+                                       "requestBody": {},
+                                       "responses": {
+                                               "default": {
+                                                       "description": ""
+                                               }
+                                       },
+                                       "x-apisix-enable_websocket": false,
+                                       "x-apisix-hosts": ["test.com"],
+                                       "x-apisix-priority": 0,
+                                       "x-apisix-status": 1,
+                                       "x-apisix-upstream": {
+                                               "nodes": {
+                                                       "172.16.238.20:1980": 1
+                                               },
+                                               "type": "roundrobin"
+                                       }
+                               },
+                               "post": {
+                                       "operationId": "route_allPOST",
+                                       "requestBody": {},
+                                       "responses": {
+                                               "default": {
+                                                       "description": ""
+                                               }
+                                       },
+                                       "x-apisix-enable_websocket": false,
+                                       "x-apisix-hosts": ["test.com"],
+                                       "x-apisix-priority": 0,
+                                       "x-apisix-status": 1,
+                                       "x-apisix-upstream": {
+                                               "nodes": {
+                                                       "172.16.238.20:1980": 1
+                                               },
+                                               "type": "roundrobin"
+                                       }
+                               },
+                               "put": {
+                                       "operationId": "route_allPUT",
+                                       "requestBody": {},
+                                       "responses": {
+                                               "default": {
+                                                       "description": ""
+                                               }
+                                       },
+                                       "x-apisix-enable_websocket": false,
+                                       "x-apisix-hosts": ["test.com"],
+                                       "x-apisix-priority": 0,
+                                       "x-apisix-status": 1,
+                                       "x-apisix-upstream": {
+                                               "nodes": {
+                                                       "172.16.238.20:1980": 1
+                                               },
+                                               "type": "roundrobin"
+                                       }

Review comment:
       They are the same. Can we use a variable instead?
   
   ```
                                           "requestBody": {},
                                        "responses": {
                                                "default": {
                                                        "description": ""
                                                }
                                        },
                                        "x-apisix-enable_websocket": false,
                                        "x-apisix-hosts": ["test.com"],
                                        "x-apisix-priority": 0,
                                        "x-apisix-status": 1,
                                        "x-apisix-upstream": {
                                                "nodes": {
                                                        "172.16.238.20:1980": 1
                                                },
                                                "type": "roundrobin"
                                        }
   ```




-- 
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:
us...@infra.apache.org


Reply via email to