From bcd316a44e2f80464370ed83eb6db28d0a8150d9 Mon Sep 17 00:00:00 2001 From: NicoYuan1986 <109071306+NicoYuan1986@users.noreply.github.com> Date: Thu, 9 Mar 2023 19:13:52 +0800 Subject: [PATCH] Add test case of Varchar limits (#22652) Signed-off-by: nico --- tests/python_client/testcases/test_insert.py | 21 ++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/python_client/testcases/test_insert.py b/tests/python_client/testcases/test_insert.py index 6f420a8d5e..859d6da8ab 100644 --- a/tests/python_client/testcases/test_insert.py +++ b/tests/python_client/testcases/test_insert.py @@ -496,6 +496,27 @@ class TestInsertOperation(TestcaseBase): error = {ct.err_code: 1, ct.err_msg: "The type of data should be list or pandas.DataFrame"} collection_w.insert(data=df, check_task=CheckTasks.err_res, check_items=error) + @pytest.mark.tags(CaseLabel.L1) + def test_insert_exceed_varchar_limit(self): + """ + target: test insert exceed varchar limit + method: create a collection with varchar limit=2 and insert invalid data + expected: error raised + """ + fields = [ + cf.gen_int64_field(is_primary=True), + cf.gen_float_vec_field(), + cf.gen_string_field(name='small_limit', max_length=2), + cf.gen_string_field(name='big_limit', max_length=65530) + ] + schema = cf.gen_collection_schema(fields, auto_id=True) + name = cf.gen_unique_str(prefix) + collection_w = self.init_collection_wrap(name, schema) + vectors = cf.gen_vectors(2, ct.default_dim) + data = [vectors, ["limit_1___________", "limit_2___________"], ['1', '2']] + error = {ct.err_code: 1, ct.err_msg: "invalid input, length of string exceeds max length"} + collection_w.insert(data, check_task=CheckTasks.err_res, check_items=error) + @pytest.mark.tags(CaseLabel.L2) def test_insert_with_lack_vector_field(self): """