blackmwk commented on code in PR #3102:
URL: https://github.com/apache/iceberg-rust/pull/3102#discussion_r4268444635
##########
crates/catalog/glue/src/catalog.rs:
##########
@@ -959,3 +936,89 @@ impl Catalog for GlueCatalog {
Ok(staged_table)
}
}
+
+#[cfg(test)]
+mod catalog_properties_tests {
Review Comment:
```suggestion
mod tests {
```
##########
crates/catalog/glue/src/catalog.rs:
##########
@@ -959,3 +936,89 @@ impl Catalog for GlueCatalog {
Ok(staged_table)
}
}
+
+#[cfg(test)]
+mod catalog_properties_tests {
+ use iceberg::io::MemoryStorageFactory;
+
+ use super::*;
+
+ #[test]
+ fn test_catalog_properties() {
+ let properties =
GlueCatalogProperties::from_properties(&HashMap::from([
+ (
+ GLUE_CATALOG_PROP_URI.to_string(),
+ "http://localhost".to_string(),
+ ),
+ (
+ GLUE_CATALOG_PROP_CATALOG_ID.to_string(),
+ "catalog".to_string(),
+ ),
+ (
+ GLUE_CATALOG_PROP_WAREHOUSE.to_string(),
+ "s3://warehouse".to_string(),
+ ),
+ ]))
+ .unwrap();
+
+ assert_eq!(properties.uri.as_deref(), Some("http://localhost"));
+ assert_eq!(properties.catalog_id.as_deref(), Some("catalog"));
+ assert_eq!(properties.warehouse, "s3://warehouse");
+ }
+
+ #[test]
+ fn test_catalog_properties_defaults() {
+ let properties =
GlueCatalogProperties::from_properties(&HashMap::new()).unwrap();
+
+ assert_eq!(properties.uri, None);
+ assert_eq!(properties.catalog_id, None);
+ assert_eq!(properties.warehouse, "");
+ }
+
+ #[tokio::test]
+ async fn test_load_rejects_missing_or_empty_warehouse() {
+ for props in [
+ HashMap::new(),
+ HashMap::from([(GLUE_CATALOG_PROP_WAREHOUSE.to_string(),
String::new())]),
+ ] {
+ let error = GlueCatalogBuilder::default()
+ .load("glue", props)
+ .await
+ .unwrap_err();
+
+ assert_eq!(error.kind(), ErrorKind::DataInvalid);
+ assert_eq!(error.message(), "Catalog warehouse is required");
+ }
+ }
+
+ #[tokio::test]
Review Comment:
Remove this, it's stupid.
##########
crates/catalog/glue/src/catalog.rs:
##########
@@ -57,22 +58,15 @@ pub const GLUE_CATALOG_PROP_WAREHOUSE: &str = "warehouse";
/// Builder for [`GlueCatalog`].
#[derive(Debug)]
pub struct GlueCatalogBuilder {
- config: GlueCatalogConfig,
storage_factory: Option<Arc<dyn StorageFactory>>,
kms_client_factory: Option<Arc<dyn KmsClientFactory>>,
runtime: Option<Runtime>,
}
+#[allow(clippy::derivable_impls)]
Review Comment:
Remove this, just derive Default.
--
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]