Add test for generating static delta to file
authorManuel Stühn <freebsd@justmail.de>
Thu, 30 Jun 2022 07:06:30 +0000 (09:06 +0200)
committerLuca BRUNO <luca.bruno@coreos.com>
Thu, 13 Oct 2022 16:29:58 +0000 (16:29 +0000)
rust-bindings/tests/repo/generate_static.rs [new file with mode: 0644]
rust-bindings/tests/repo/mod.rs

diff --git a/rust-bindings/tests/repo/generate_static.rs b/rust-bindings/tests/repo/generate_static.rs
new file mode 100644 (file)
index 0000000..b2f3cd7
--- /dev/null
@@ -0,0 +1,42 @@
+use crate::util::*;
+use gio::NONE_CANCELLABLE;
+use ostree::glib::prelude::*;
+use ostree::glib::Variant;
+use ostree::*;
+
+use std::collections::HashMap;
+
+#[test]
+fn should_generate_static_delta_at() {
+    let mut options: HashMap<String, Variant> = HashMap::<String, Variant>::new();
+
+    let delta_dir = tempfile::tempdir().expect("static delta dir");
+    let delta_path = delta_dir.path().join("static_delta.file");
+    let path_var = delta_path
+        .to_str()
+        .expect("no valid path")
+        .as_bytes()
+        .to_variant();
+
+    let test_repo = TestRepo::new();
+    let from = test_repo.test_commit("commit1");
+    let to = test_repo.test_commit("commit2");
+
+    options.insert(String::from("filename"), path_var);
+
+    let varopts = &options.to_variant();
+
+    let _result = test_repo
+        .repo
+        .static_delta_generate(
+            ostree::StaticDeltaGenerateOpt::Major,
+            Some(&from),
+            &to,
+            None,
+            Some(varopts),
+            NONE_CANCELLABLE,
+        )
+        .expect("static delta generate");
+
+    assert!(std::fs::File::open(&delta_path).is_err());
+}
index 0a94eb9f7d62e62c880065d680a922a3ea757f21..0f8967a0c5318d76d8a44a1b3d6bd457fb62c820 100644 (file)
@@ -5,6 +5,7 @@ use ostree::{ObjectName, ObjectType};
 
 #[cfg(feature = "v2016_8")]
 mod checkout_at;
+mod generate_static;
 
 #[test]
 fn should_commit_content_to_repo_and_list_refs_again() {