Implement ostree::checksum_file_from_input

This commit is contained in:
Felix Krull authored and Colin Walters committed 2022-05-06 12:53:54 -04:00
1 parent 7f3bd56d0d
commit 14f2ff43df
2 files changed
+62 -1

No files matched your search

+30 -1
View File
@@ -1,6 +1,6 @@
use gio::NONE_CANCELLABLE;
use glib::Cast;
use ostree::{checksum_file, ObjectType, RepoFile, RepoFileExt};
use ostree::{checksum_file, checksum_file_from_input, ObjectType, RepoFile, RepoFileExt};
use util::TestRepo;
#[test]
@@ -19,3 +19,32 @@ fn should_checksum_file() {
assert_eq!(file.get_checksum().unwrap(), result.to_string());
}
#[test]
fn should_checksum_file_from_input() {
let repo = TestRepo::new();
let commit_checksum = repo.test_commit("test");
let objects = repo
.repo
.traverse_commit(&commit_checksum, -1, NONE_CANCELLABLE)
.expect("traverse commit");
for obj in objects {
if obj.object_type() != ObjectType::File {
continue;
}
let (stream, file_info, xattrs) = repo
.repo
.load_file(obj.checksum(), NONE_CANCELLABLE)
.expect("load file");
let result = checksum_file_from_input(
file_info.as_ref().unwrap(),
xattrs.as_ref(),
stream.as_ref(),
ObjectType::File,
NONE_CANCELLABLE,
)
.expect("checksum file from input");
assert_eq!(obj.checksum(), result.to_string());
}
}