gaborkaszab commented on code in PR #15903:
URL: https://github.com/apache/iceberg/pull/15903#discussion_r3333269794
##########
core/src/test/java/org/apache/iceberg/rest/TestRESTScanPlanning.java:
##########
@@ -1576,4 +1577,84 @@ public void
clientRequestsClientAndServerReturnsNothing() {
assertThat(table).isNotInstanceOf(RESTTable.class);
assertThat(table).isInstanceOf(BaseTable.class);
}
+
+ @Test
+ public void defaultPlanningModeWhenNoneSpecified() {
+ CatalogWithAdapter catalogWithAdapter = catalogWithModes(null, null);
+ catalogWithAdapter.catalog.createNamespace(NS);
+
+ Table table =
+ catalogWithAdapter
+ .catalog
+ .buildTable(TableIdentifier.of(NS, "default_mode_test"), SCHEMA)
+ .create();
+
+
assertThat(table).isNotInstanceOf(RESTTable.class).isInstanceOf(BaseTable.class);
+ }
+
+ @Test
+ public void invalidPlanningModeConfiguredForClient() {
+ assertThatThrownBy(
+ () ->
+ catalogWithModes(
+ "invalid_mode",
RESTCatalogProperties.ScanPlanningMode.CLIENT.modeName()))
+ .isInstanceOf(IllegalArgumentException.class)
+ .hasMessageContaining("Invalid scan planning mode: invalid_mode");
+ }
+
+ @Test
+ public void invalidPlanningModeConfiguredForServer() {
+ CatalogWithAdapter catalogWithAdapter =
+
catalogWithModes(RESTCatalogProperties.ScanPlanningMode.CLIENT.modeName(),
"invalid_mode");
+ catalogWithAdapter.catalog.createNamespace(NS);
+
+ assertThatThrownBy(
+ () ->
+ catalogWithAdapter
+ .catalog
+ .buildTable(TableIdentifier.of(NS,
"invalid_server_mode_test"), SCHEMA)
+ .create())
+ .isInstanceOf(IllegalArgumentException.class)
+ .hasMessageContaining("Invalid scan planning mode: invalid_mode");
+ }
+
+ @ParameterizedTest
+ @ValueSource(
+ strings = {"client", "CLIENT", "Client", "cLiEnT", "server", "SERVER",
"Server", "sErVeR"})
+ public void planningModeWithDifferentCasesOnClient(String planningMode) {
+ CatalogWithAdapter catalogWithAdapter = catalogWithModes(planningMode,
null);
+ catalogWithAdapter.catalog.createNamespace(NS);
+
+ Table table =
+ catalogWithAdapter
+ .catalog
+ .buildTable(TableIdentifier.of(NS, "client_case_test_" +
planningMode), SCHEMA)
+ .create();
+
+ if (planningMode.equalsIgnoreCase("client")) {
+
assertThat(table).isNotInstanceOf(RESTTable.class).isInstanceOf(BaseTable.class);
+ } else {
+ assertThat(table).isInstanceOf(RESTTable.class);
+ }
Review Comment:
I generally think in tests give more readability to spell out such things
instead of extracting to functions. I introduced a function here as you
suggested. WDYT?
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]