mirror of
https://github.com/outbackdingo/firezone.git
synced 2026-01-27 10:18:54 +00:00
test(gui-client): fix missed mutations (#3753)
I added unit tests for these pure or mostly-pure functions that `cargo-mutants` said were not covered. It also picked up a lot of I/O-performing functions that I ignored for now. (They're hard to test)
This commit is contained in:
@@ -10,3 +10,17 @@ pub(crate) fn get_cargo_version() -> String {
|
||||
pub(crate) fn get_git_version() -> String {
|
||||
GIT_VERSION.to_string()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
#[test]
|
||||
fn version() {
|
||||
let cargo = super::get_cargo_version();
|
||||
let git = super::get_git_version();
|
||||
|
||||
assert!(cargo != "Unknown", "{}", cargo);
|
||||
assert!(git != "Unknown", "{}", git);
|
||||
assert!(cargo.len() >= 2, "{}", cargo);
|
||||
assert!(git.len() >= 6, "{}", git);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -267,6 +267,14 @@ mod tests {
|
||||
SecretString::new(x.into())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn actor_name_path() {
|
||||
assert!(super::actor_name_path()
|
||||
.expect("`actor_name_path` should return Ok")
|
||||
.components()
|
||||
.any(|x| x == std::path::Component::Normal("dev.firezone.client".as_ref())));
|
||||
}
|
||||
|
||||
/// Runs everything in one test so that `cargo test` can't multi-thread it
|
||||
/// This should work around a bug we had <https://github.com/firezone/firezone/issues/3256>
|
||||
#[test]
|
||||
|
||||
@@ -162,3 +162,14 @@ fn set_registry_values(id: &str, exe: &str) -> Result<(), io::Error> {
|
||||
fn named_pipe_path(id: &str) -> String {
|
||||
format!(r"\\.\pipe\{}", id)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
#[test]
|
||||
fn named_pipe_path() {
|
||||
assert_eq!(
|
||||
super::named_pipe_path("dev.firezone.client"),
|
||||
r"\\.\pipe\dev.firezone.client"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,3 +118,18 @@ mod imp {
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn smoke() {
|
||||
for dir in [device_id(), logs(), runtime(), session(), settings()] {
|
||||
let dir = dir.expect("should have gotten Some(path)");
|
||||
assert!(dir
|
||||
.components()
|
||||
.any(|x| x == std::path::Component::Normal("dev.firezone.client".as_ref())));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user