extern crate systemd;
use systemd::login;
use systemd::daemon::booted;
#[test]
fn test_get_unit() {
let uu = login::get_unit(login::UnitType::UserUnit, None);
let su = login::get_unit(login::UnitType::SystemUnit, None);
let has_systemd = booted();
assert!(has_systemd.is_ok());
match has_systemd.unwrap() {
false => { assert!(uu.is_err()); assert!(su.is_err()); },
true => { assert_eq!(uu.is_err(), su.is_ok()); },
};
}
#[test]
fn test_get_slice() {
let us = login::get_slice(login::UnitType::UserUnit, None);
let ss = login::get_slice(login::UnitType::SystemUnit, None);
let has_systemd = booted();
assert!(has_systemd.is_ok());
match has_systemd.unwrap() {
false => { assert_eq!(ss.unwrap(), "-.slice"); },
true => { assert!(ss.is_ok() || us.is_ok()); },
};
}
#[test]
fn test_get_machine_name() {
let mname = login::get_machine_name(None);
let has_systemd = booted();
assert!(has_systemd.is_ok());
match has_systemd.unwrap() {
false => { assert!(mname.is_err()); },
true => { },
};
}
#[test]
fn test_get_cgroup() {
let cg = login::get_cgroup(None);
let has_systemd = booted();
assert!(has_systemd.is_ok());
match has_systemd.unwrap() {
true => { assert!(cg.is_ok()) },
false => { },
};
}
#[test]
fn test_get_session() {
let ss = login::get_session(None);
let has_systemd = booted();
assert!(has_systemd.is_ok());
match has_systemd.unwrap() {
true => { assert!(ss.is_ok()) },
false => { },
};
}
#[test]
fn test_get_owner_uid() {
let ou = login::get_owner_uid(None);
let has_systemd = booted();
assert!(has_systemd.is_ok());
match has_systemd.unwrap() {
true => { assert!(ou.is_ok()) },
false => { },
};
}