apisix-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [apisix-dashboard] Jaycean commented on a change in pull request #1384: fix: When exporting route, whether the parameter is empty or not
Date Thu, 28 Jan 2021 01:27:12 GMT

Jaycean commented on a change in pull request #1384:
URL: https://github.com/apache/apisix-dashboard/pull/1384#discussion_r565757753



##########
File path: api/internal/handler/data_loader/route_export_test.go
##########
@@ -1903,10 +1904,66 @@ func TestExportRoutesSameURI(t *testing.T) {
 	assert.True(t, getCalled)
 }
 
+func TestExportRoutesParameterEmpty(t *testing.T) {
+	// Error test when pass parameter is null
+	r1 := `{
+		"uris": ["/test-test"],
+		"name": "route_all",
+		"desc": "所有",
+		"methods": ["GET"],
+		"hosts": ["test.com"],
+		"status": 1,
+		"upstream": {
+			"nodes": {
+				"172.16.238.20:1980": 1
+			},
+			"type": "roundrobin"
+		}
+}`
+	var route *entity.Route
+	err := json.Unmarshal([]byte(r1), &route)
+	assert.Nil(t, err)
+	mStore := &store.MockInterface{}
+	mStore.On("Get", mock.Anything).Run(func(args mock.Arguments) {
+	}).Return(route, nil)
+
+	h := Handler{routeStore: mStore}
+	exportInput := &ExportInput{}
+	exportInput.IDs = ""
+	ctx := droplet.NewContext()
+	ctx.SetInput(exportInput)
+	_, err1 := h.ExportRoutes(ctx)
+	assert.Equal(t, errors.New("Parameter IDs cannot be empty"), err1)

Review comment:
       I personally think that this return error is used by this test alone and only once.
I don't think it's necessary to declare a new variable




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



Mime
View raw message