mirror of
https://github.com/ostreedev/ostree.git
synced 2025-01-11 09:18:20 +03:00
Merge pull request #2663 from mstuehn/test-static-delta-file
lib/static-delta: document and check parameters format
This commit is contained in:
commit
a19cc34883
44
rust-bindings/tests/repo/generate_static.rs
Normal file
44
rust-bindings/tests/repo/generate_static.rs
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
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()
|
||||||
|
.map(std::ffi::CString::new)
|
||||||
|
.expect("no valid path")
|
||||||
|
.unwrap()
|
||||||
|
.as_bytes_with_nul()
|
||||||
|
.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!(delta_path.try_exists().unwrap());
|
||||||
|
}
|
@ -5,6 +5,7 @@ use ostree::{ObjectName, ObjectType};
|
|||||||
|
|
||||||
#[cfg(feature = "v2016_8")]
|
#[cfg(feature = "v2016_8")]
|
||||||
mod checkout_at;
|
mod checkout_at;
|
||||||
|
mod generate_static;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn should_commit_content_to_repo_and_list_refs_again() {
|
fn should_commit_content_to_repo_and_list_refs_again() {
|
||||||
|
@ -1334,9 +1334,9 @@ get_fallback_headers (OstreeRepo *self,
|
|||||||
* - inline-parts: b: Put part data in header, to get a single file delta. Default FALSE.
|
* - inline-parts: b: Put part data in header, to get a single file delta. Default FALSE.
|
||||||
* - verbose: b: Print diagnostic messages. Default FALSE.
|
* - verbose: b: Print diagnostic messages. Default FALSE.
|
||||||
* - endianness: b: Deltas use host byte order by default; this option allows choosing (G_BIG_ENDIAN or G_LITTLE_ENDIAN)
|
* - endianness: b: Deltas use host byte order by default; this option allows choosing (G_BIG_ENDIAN or G_LITTLE_ENDIAN)
|
||||||
* - filename: ay: Save delta superblock to this filename, and parts in the same directory. Default saves to repository.
|
* - filename: ^ay: Save delta superblock to this filename (bytestring), and parts in the same directory. Default saves to repository.
|
||||||
* - sign-name: ay: Signature type to use.
|
* - sign-name: ^ay: Signature type to use (bytestring).
|
||||||
* - sign-key-ids: as: Array of keys used to sign delta superblock.
|
* - sign-key-ids: ^as: NULL-terminated array of keys used to sign delta superblock.
|
||||||
*/
|
*/
|
||||||
gboolean
|
gboolean
|
||||||
ostree_repo_static_delta_generate (OstreeRepo *self,
|
ostree_repo_static_delta_generate (OstreeRepo *self,
|
||||||
@ -1409,9 +1409,13 @@ ostree_repo_static_delta_generate (OstreeRepo *self,
|
|||||||
|
|
||||||
if (!g_variant_lookup (params, "filename", "^&ay", &opt_filename))
|
if (!g_variant_lookup (params, "filename", "^&ay", &opt_filename))
|
||||||
opt_filename = NULL;
|
opt_filename = NULL;
|
||||||
|
else if (opt_filename[0] == '\0')
|
||||||
|
return glnx_throw (error, "Invalid 'filename' parameter");
|
||||||
|
|
||||||
if (!g_variant_lookup (params, "sign-name", "^&ay", &opt_sign_name))
|
if (!g_variant_lookup (params, "sign-name", "^&ay", &opt_sign_name))
|
||||||
opt_sign_name = NULL;
|
opt_sign_name = NULL;
|
||||||
|
else if (opt_sign_name[0] == '\0')
|
||||||
|
return glnx_throw (error, "Invalid 'sign-name' parameter");
|
||||||
|
|
||||||
if (!g_variant_lookup (params, "sign-key-ids", "^a&s", &opt_key_ids))
|
if (!g_variant_lookup (params, "sign-key-ids", "^a&s", &opt_key_ids))
|
||||||
opt_key_ids = NULL;
|
opt_key_ids = NULL;
|
||||||
|
Loading…
Reference in New Issue
Block a user