You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by GitBox <gi...@apache.org> on 2021/08/12 02:46:21 UTC

[GitHub] [servicecomb-kie] little-cui commented on a change in pull request #196: the maximum value of kie is 128KB

little-cui commented on a change in pull request #196:
URL: https://github.com/apache/servicecomb-kie/pull/196#discussion_r687326316



##########
File path: server/resource/v1/kv_resource_test.go
##########
@@ -216,6 +223,41 @@ func TestKVResource_Post(t *testing.T) {
 		c.ServeHTTP(resp, r)
 		assert.Equal(t, http.StatusBadRequest, resp.Result().StatusCode)
 	})
+	t.Run("post kv, length of value is 131072, should success", func(t *testing.T) {
+		kv := &model.KVDoc{
+			Key:   "value-max-size",
+			Value: string131072,
+		}
+		j, _ := json.Marshal(kv)
+		r, _ := http.NewRequest("POST", "/v1/kv_test/kie/kv", bytes.NewBuffer(j))
+		r.Header.Set("Content-Type", "application/json")
+		kvr := &v1.KVResource{}
+		c, _ := restfultest.New(kvr, nil)
+		resp := httptest.NewRecorder()
+		c.ServeHTTP(resp, r)
+		assert.Equal(t, http.StatusOK, resp.Result().StatusCode)
+
+		body, err := ioutil.ReadAll(resp.Body)
+		assert.NoError(t, err)
+		data := &model.KVDoc{}
+		err = json.Unmarshal(body, data)
+		assert.NoError(t, err)
+		assert.Equal(t, 131072, len(data.Value))
+	})
+	t.Run("post kv, length of value is 131073, should return err", func(t *testing.T) {
+		kv := &model.KVDoc{
+			Key:   "value-max-size",
+			Value: string131072 + "a",
+		}
+		j, _ := json.Marshal(kv)
+		r, _ := http.NewRequest("POST", "/v1/kv_test/kie/kv", bytes.NewBuffer(j))
+		r.Header.Set("Content-Type", "application/json")
+		kvr := &v1.KVResource{}
+		c, _ := restfultest.New(kvr, nil)
+		resp := httptest.NewRecorder()
+		c.ServeHTTP(resp, r)
+		assert.Equal(t, http.StatusBadRequest, resp.Result().StatusCode)
+	})

Review comment:
       缺少导入API的UT




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

To unsubscribe, e-mail: commits-unsubscribe@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org