blackmwk commented on code in PR #2821:
URL: https://github.com/apache/iceberg-rust/pull/2821#discussion_r3628541234


##########
crates/iceberg/src/transaction/snapshot.rs:
##########
@@ -530,3 +539,179 @@ impl<'a> SnapshotProducer<'a> {
         Ok(ActionCommit::new(updates, requirements))
     }
 }
+
+#[cfg(test)]
+mod tests {
+    use std::collections::HashMap;
+    use std::fs::File;
+    use std::io::BufReader;
+    use std::sync::Arc;
+
+    use uuid::Uuid;
+
+    use super::SnapshotProducer;
+    use crate::TableIdent;
+    use crate::encryption::kms::{KeyManagementClient, 
MemoryKeyManagementClient};
+    use crate::encryption::{SensitiveBytes, StandardKeyMetadata};
+    use crate::io::FileIO;
+    use crate::spec::{
+        DataContentType, DataFileBuilder, DataFileFormat, Manifest, 
ManifestContentType,
+        ManifestStatus, Struct, TableMetadata,
+    };
+    use crate::table::Table;
+    use crate::test_utils::test_runtime;
+
+    /// Build a table backed by the V3 encryption fixture and an in-memory KMS,
+    /// so it has an 
[`EncryptionManager`](crate::encryption::EncryptionManager).
+    fn make_encrypted_table() -> Table {
+        let file = File::open(format!(
+            "{}/testdata/table_metadata/{}",
+            env!("CARGO_MANIFEST_DIR"),
+            "TableMetadataV3ValidEncryption.json"
+        ))
+        .unwrap();
+        let reader = BufReader::new(file);
+        let metadata = serde_json::from_reader::<_, 
TableMetadata>(reader).unwrap();
+
+        let kms: Arc<dyn KeyManagementClient> = {
+            let k = MemoryKeyManagementClient::new();
+            k.add_master_key_bytes(
+                "master-1",
+                SensitiveBytes::new([
+                    0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 
0x09, 0x0a, 0x0b, 0x0c,
+                    0x0d, 0x0e, 0x0f,
+                ]),
+            )
+            .unwrap();
+            Arc::new(k)
+        };
+
+        Table::builder()
+            .metadata(metadata)
+            .metadata_location("memory:///table/metadata/v1.json")
+            .identifier(TableIdent::from_strs(["ns1", "test1"]).unwrap())
+            .file_io(FileIO::new_with_memory())
+            .kms_client(kms)
+            .runtime(test_runtime())
+            .build()
+            .unwrap()
+    }
+
+    fn data_file() -> crate::spec::DataFile {
+        DataFileBuilder::default()
+            .content(DataContentType::Data)
+            .file_path("memory:///table/data/00000.parquet".to_string())
+            .file_format(DataFileFormat::Parquet)
+            .partition(Struct::empty())
+            .record_count(100)
+            .file_size_in_bytes(4096)
+            .partition_spec_id(0)
+            .build()
+            .unwrap()
+    }
+
+    #[tokio::test]
+    async fn write_encrypted_manifest_roundtrips() {

Review Comment:
   I'm hesitating to add test for such low level apis here. I think you add a 
test in one of the snapshot producing operator like `FastAppend` to test



-- 
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]

Reply via email to