add mockrepo tests
This commit is contained in:
71
tests/profile/read_mock_profile.rs
Normal file
71
tests/profile/read_mock_profile.rs
Normal file
@@ -0,0 +1,71 @@
|
||||
use std::env::args;
|
||||
|
||||
use gentoo_utils::{atom::Atom, repo::Repo, useflag::UseFlag};
|
||||
use itertools::Itertools;
|
||||
|
||||
fn main() {
|
||||
let repo_path = args()
|
||||
.nth(1)
|
||||
.expect("expected path to mockrepo as first argument");
|
||||
let repo = Repo::new(&repo_path).expect("failed to read repo");
|
||||
let profile = repo
|
||||
.evaluate_profile("gentoo-desktop")
|
||||
.expect("failed to evaluate profile");
|
||||
|
||||
let r#use = profile.make_defaults()["USE"]
|
||||
.split_ascii_whitespace()
|
||||
.sorted()
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
assert_eq!(r#use, vec!["emacs", "selinux",]);
|
||||
|
||||
let packages = profile
|
||||
.packages()
|
||||
.iter()
|
||||
.map(Atom::to_string)
|
||||
.sorted()
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
assert_eq!(
|
||||
packages,
|
||||
vec!["app-editors/emacs", "sec-policy/selinux-base"]
|
||||
);
|
||||
|
||||
let packages_mask = profile
|
||||
.package_mask()
|
||||
.iter()
|
||||
.map(Atom::to_string)
|
||||
.sorted()
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
assert_eq!(packages_mask, vec!["app-editors/vim"]);
|
||||
|
||||
let emacs_use = profile
|
||||
.package_use()
|
||||
.iter()
|
||||
.find_map(|(atom, flags)| {
|
||||
if atom.clone().into_cp().to_string() == "app-editors/emacs" {
|
||||
Some(flags)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
.unwrap()
|
||||
.iter()
|
||||
.map(UseFlag::to_string)
|
||||
.sorted()
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
assert_eq!(emacs_use, vec!["gui"]);
|
||||
|
||||
let use_force = profile
|
||||
.use_force()
|
||||
.iter()
|
||||
.map(UseFlag::to_string)
|
||||
.sorted()
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
assert_eq!(use_force, vec!["base", "caps", "default", "gui"]);
|
||||
|
||||
assert!(profile.use_mask().is_empty());
|
||||
}
|
||||
Reference in New Issue
Block a user