mirror of
https://github.com/ostreedev/ostree.git
synced 2025-01-26 14:04:12 +03:00
Add test for checkout_tree
This commit is contained in:
parent
1068d4f619
commit
80de2aa2ea
@ -8,8 +8,9 @@ extern crate maplit;
|
||||
mod util;
|
||||
use util::*;
|
||||
|
||||
use gio::prelude::*;
|
||||
use gio::NONE_CANCELLABLE;
|
||||
use ostree::prelude::*;
|
||||
use glib::prelude::*;
|
||||
use ostree::{ObjectName, ObjectType};
|
||||
|
||||
#[test]
|
||||
@ -31,7 +32,7 @@ fn should_commit_content_to_repo_and_list_refs_again() {
|
||||
#[test]
|
||||
fn should_traverse_commit() {
|
||||
let test_repo = TestRepo::new();
|
||||
let checksum = test_repo.test_commit();
|
||||
let checksum = test_repo.test_commit("test");
|
||||
|
||||
let objects = test_repo
|
||||
.repo
|
||||
@ -61,3 +62,40 @@ fn should_traverse_commit() {
|
||||
objects
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn should_checkout_tree() {
|
||||
let test_repo = TestRepo::new();
|
||||
let _ = test_repo.test_commit("test");
|
||||
|
||||
let checkout_dir = tempfile::tempdir().expect("checkout dir");
|
||||
let file = test_repo
|
||||
.repo
|
||||
.read_commit("test", NONE_CANCELLABLE)
|
||||
.expect("read commit")
|
||||
.0
|
||||
.downcast::<ostree::RepoFile>()
|
||||
.expect("RepoFile");
|
||||
let info = file
|
||||
.query_info("*", gio::FileQueryInfoFlags::NONE, NONE_CANCELLABLE)
|
||||
.expect("file info");
|
||||
test_repo
|
||||
.repo
|
||||
.checkout_tree(
|
||||
ostree::RepoCheckoutMode::User,
|
||||
ostree::RepoCheckoutOverwriteMode::None,
|
||||
&gio::File::new_for_path(checkout_dir.path().join("test-checkout")),
|
||||
&file,
|
||||
&info,
|
||||
NONE_CANCELLABLE,
|
||||
)
|
||||
.expect("checkout tree");
|
||||
|
||||
let testfile_path = checkout_dir
|
||||
.path()
|
||||
.join("test-checkout")
|
||||
.join("testdir")
|
||||
.join("testfile");
|
||||
let testfile_contents = std::fs::read_to_string(testfile_path).expect("test file");
|
||||
assert_eq!("test\n", testfile_contents);
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
use gio::NONE_CANCELLABLE;
|
||||
use glib::prelude::*;
|
||||
use glib::GString;
|
||||
use ostree::prelude::*;
|
||||
use std::path::Path;
|
||||
|
||||
#[derive(Debug)]
|
||||
@ -23,9 +22,9 @@ impl TestRepo {
|
||||
TestRepo { dir, repo }
|
||||
}
|
||||
|
||||
pub fn test_commit(&self) -> GString {
|
||||
pub fn test_commit(&self, ref_: &str) -> GString {
|
||||
let mtree = create_mtree(&self.repo);
|
||||
commit(&self.repo, &mtree, "test")
|
||||
commit(&self.repo, &mtree, ref_)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user