Skip to content

Commit 9973f92

Browse files
committed
Refactoring + allowedCharacters test
1 parent 9c799c4 commit 9973f92

File tree

2 files changed

+28
-25
lines changed

2 files changed

+28
-25
lines changed

ydb/core/kqp/ut/olap/olap_columns_ut.cpp renamed to ydb/core/kqp/ut/olap/column_name_validation_ut.cpp

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ Y_UNIT_TEST_SUITE(NamingValidation) {
1717
NYdb::TKikimrWithGrpcAndRootSchema server(GetAppConfig());
1818
Tests::TClient annoyingClient(*server.ServerSettings);
1919

20-
TString tableName = "test";
21-
TString tableDescr = R"(
20+
TString allowedChars = "_-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
21+
22+
TString tableDescr = Sprintf(R"(
2223
Name: "TestTable"
2324
Schema {
2425
Columns {
@@ -27,12 +28,12 @@ Y_UNIT_TEST_SUITE(NamingValidation) {
2728
NotNull: True
2829
}
2930
Columns {
30-
Name: "message"
31+
Name: "%s"
3132
Type: "Utf8"
3233
}
3334
KeyColumnNames: ["Id"]
3435
}
35-
)";
36+
)", allowedChars.c_str());
3637

3738
NMsgBusProxy::EResponseStatus status = annoyingClient.CreateColumnTable("/Root", tableDescr);
3839

@@ -43,25 +44,29 @@ Y_UNIT_TEST_SUITE(NamingValidation) {
4344
NYdb::TKikimrWithGrpcAndRootSchema server(GetAppConfig());
4445
Tests::TClient annoyingClient(*server.ServerSettings);
4546

46-
TString tableDescr = R"(
47-
Name: "TestTable"
48-
Schema {
49-
Columns {
50-
Name: "Id"
51-
Type: "Int32"
52-
NotNull: True
53-
}
54-
Columns {
55-
Name: "mess age"
56-
Type: "Utf8"
57-
}
58-
KeyColumnNames: ["Id"]
59-
}
60-
)";
61-
62-
NMsgBusProxy::EResponseStatus status = annoyingClient.CreateColumnTable("/Root", tableDescr);
47+
TVector<TString> notAllowedNames = {"mess age", "~!@#$%^&*()+=asdfa"};
6348

64-
UNIT_ASSERT_VALUES_EQUAL(status, NMsgBusProxy::EResponseStatus::MSTATUS_ERROR);
49+
for (const auto& colName: notAllowedNames) {
50+
TString tableDescr = Sprintf(R"(
51+
Name: "TestTable"
52+
Schema {
53+
Columns {
54+
Name: "Id"
55+
Type: "Int32"
56+
NotNull: True
57+
}
58+
Columns {
59+
Name: "%s"
60+
Type: "Utf8"
61+
}
62+
KeyColumnNames: ["Id"]
63+
}
64+
)", colName.c_str());
65+
66+
NMsgBusProxy::EResponseStatus status = annoyingClient.CreateColumnTable("/Root", tableDescr);
67+
68+
UNIT_ASSERT_VALUES_EQUAL(status, NMsgBusProxy::EResponseStatus::MSTATUS_ERROR);
69+
}
6570
}
6671

6772
Y_UNIT_TEST(CreateColumnStoreOk) {
@@ -116,7 +121,6 @@ Y_UNIT_TEST_SUITE(NamingValidation) {
116121
NYdb::TKikimrWithGrpcAndRootSchema server(GetAppConfig());
117122
Tests::TClient annoyingClient(*server.ServerSettings);
118123

119-
TString tableName = "test";
120124
TString tableDescr = R"(
121125
Name: "TestTable"
122126
Schema {
@@ -154,7 +158,6 @@ Y_UNIT_TEST_SUITE(NamingValidation) {
154158
NYdb::TKikimrWithGrpcAndRootSchema server(GetAppConfig());
155159
Tests::TClient annoyingClient(*server.ServerSettings);
156160

157-
TString tableName = "test";
158161
TString tableDescr = R"(
159162
Name: "TestTable"
160163
Schema {

ydb/core/kqp/ut/olap/ya.make

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ SRCS(
2929
sys_view_ut.cpp
3030
tiering_ut.cpp
3131
write_ut.cpp
32-
olap_columns_ut.cpp
32+
column_name_validation_ut.cpp
3333
)
3434

3535
PEERDIR(

0 commit comments

Comments
 (0)