- 2001
"a unit that does not exist is owned by nobody" - 2002
); - 2003
} - 2004
- 2005
/// Configured and activated are different states, and the difference - 2006
/// has to be visible: a bot in `bots.json` with no unit file is one an - 2007
/// operator created but has not activated yet, not a fault. - 2008
#[test] - 2009
fn a_configured_bot_without_a_unit_reads_as_not_registered() { - 2010
let data = tempfile::tempdir().unwrap(); - 2011
let units = tempfile::tempdir().unwrap(); - 2012
let paths = Paths { - 2013
launch_agents_dir: units.path().to_path_buf(), - 2014
systemd_unit_dir: units.path().to_path_buf(), - 2015
}; - 2016
assert!(configured_bot_service_names_all(data.path()).is_empty()); - 2017
- 2018
write_bots_json(data.path(), &[("VakBot", "telegram")]); - 2019
let names = configured_bot_service_names_all(data.path()); - 2020
assert_eq!(names, vec!["com.vak.telegram-VakBot"]); - 2021
assert!( - 2022
!unit_is_registered(&names[0], &paths), - 2023
"configured is not activated" - 2024
); - 2025
- 2026
std::fs::write(unit_file_path(&names[0], &paths), b"unit").unwrap(); - 2027
assert!(unit_is_registered(&names[0], &paths)); - 2028
} - 2029
- 2030
#[test] - 2031
fn configured_bot_service_names_follow_the_live_bot_store() { - 2032
let data = tempfile::tempdir().unwrap(); - 2033
write_bots_json(data.path(), &[("VakBot", "telegram"), ("Other", "discord")]); - 2034
assert_eq!( - 2035
configured_bot_service_names(data.path(), "telegram"), - 2036
vec!["com.vak.telegram-VakBot"] - 2037
); - 2038
} - 2039
- 2040
#[test] - 2041
fn uninstall_bot_units_removes_every_bot_unit_regardless_of_bots_json() { - 2042
let (_d, paths) = tmp_paths("bots-uninstall"); - 2043
let data = tempfile::tempdir().unwrap(); - 2044
let fake = Fake::with_pid(123); - 2045
- 2046
write_bots_json(data.path(), &[("VakBot", "telegram"), ("Ops", "discord")]); - 2047
sync_bots( - 2048
Path::new("/opt/vak/bin/vak"), - 2049
data.path(), - 2050
"http://127.0.0.1:8901", - 2051
&paths, - 2052
&fake, - 2053
); - 2054
assert!(unit_file_path("com.vak.telegram-VakBot", &paths).exists()); - 2055
assert!(unit_file_path("com.vak.discord-Ops", &paths).exists()); - 2056
- 2057
// Uninstall must remove every bot unit even though bots.json still - 2058
// lists them — an uninstall wants "wanted = nothing", not a diff - 2059
// against the still-present config file. - 2060
uninstall_bot_units(&paths, &fake); - 2061
assert!(!unit_file_path("com.vak.telegram-VakBot", &paths).exists()); - 2062
assert!(!unit_file_path("com.vak.discord-Ops", &paths).exists()); - 2063
} - 2064
} - 2065
Indexing the workspace…
Vakyartha documentation is discovering safe artifacts, anchors, and source references.