snuyanzin commented on code in PR #28793:
URL: https://github.com/apache/flink/pull/28793#discussion_r3699261558
##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/runtime/batch/sql/CreateConnectionITCase.java:
##########
@@ -73,6 +76,67 @@ void
testCreatePermanentConnectionRejectedWithoutSecretStore() {
.hasMessageContaining("WritableSecretStore must be
configured");
}
+ @Test
+ void testAlterConnectionRenameTemporaryConnection() {
+ tEnv().executeSql("CREATE TEMPORARY CONNECTION my_conn WITH ('k' =
'v')");
+
+ tEnv().executeSql("ALTER CONNECTION my_conn RENAME TO new_conn");
+
+
assertThat(catalogManager().getConnection(connectionIdentifier("my_conn"))).isEmpty();
+
assertThat(catalogManager().getConnection(connectionIdentifier("new_conn")))
+ .hasValueSatisfying(
+ connection ->
+
assertThat(connection.getOptions()).containsOnly(entry("k", "v")));
+ }
+
+ @Test
+ void testAlterConnectionRenameIfExists() {
+ tEnv().executeSql("ALTER CONNECTION IF EXISTS missing_conn RENAME TO
new_conn");
+
+
assertThat(catalogManager().getConnection(connectionIdentifier("new_conn"))).isEmpty();
+ }
+
+ @Test
+ void testAlterConnectionRenameToExistingConnectionRejected() {
+ tEnv().executeSql("CREATE TEMPORARY CONNECTION my_conn WITH ('k' =
'v')");
+ tEnv().executeSql("CREATE TEMPORARY CONNECTION new_conn WITH ('k' =
'v')");
+
+ assertThatThrownBy(() -> tEnv().executeSql("ALTER CONNECTION my_conn
RENAME TO new_conn"))
+ .isInstanceOf(ValidationException.class)
+ .hasMessageContaining("already exists");
Review Comment:
can. we assert the whole message instead of some part which does not tell
yet what exactly exists here
##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/runtime/batch/sql/CreateConnectionITCase.java:
##########
@@ -73,6 +76,67 @@ void
testCreatePermanentConnectionRejectedWithoutSecretStore() {
.hasMessageContaining("WritableSecretStore must be
configured");
}
+ @Test
+ void testAlterConnectionRenameTemporaryConnection() {
+ tEnv().executeSql("CREATE TEMPORARY CONNECTION my_conn WITH ('k' =
'v')");
+
+ tEnv().executeSql("ALTER CONNECTION my_conn RENAME TO new_conn");
+
+
assertThat(catalogManager().getConnection(connectionIdentifier("my_conn"))).isEmpty();
+
assertThat(catalogManager().getConnection(connectionIdentifier("new_conn")))
+ .hasValueSatisfying(
+ connection ->
+
assertThat(connection.getOptions()).containsOnly(entry("k", "v")));
+ }
+
+ @Test
+ void testAlterConnectionRenameIfExists() {
+ tEnv().executeSql("ALTER CONNECTION IF EXISTS missing_conn RENAME TO
new_conn");
+
+
assertThat(catalogManager().getConnection(connectionIdentifier("new_conn"))).isEmpty();
+ }
+
+ @Test
+ void testAlterConnectionRenameToExistingConnectionRejected() {
+ tEnv().executeSql("CREATE TEMPORARY CONNECTION my_conn WITH ('k' =
'v')");
+ tEnv().executeSql("CREATE TEMPORARY CONNECTION new_conn WITH ('k' =
'v')");
+
+ assertThatThrownBy(() -> tEnv().executeSql("ALTER CONNECTION my_conn
RENAME TO new_conn"))
+ .isInstanceOf(ValidationException.class)
+ .hasMessageContaining("already exists");
Review Comment:
can we assert the whole message instead of some part which does not tell yet
what exactly exists here
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]