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:
Reactor Scram
2024-03-04 10:58:46 -06:00
committed by GitHub
parent b8fe618093
commit fc01a3c2d0
4 changed files with 48 additions and 0 deletions

View File

@@ -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);
}
}

View File

@@ -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]

View File

@@ -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"
);
}
}

View File

@@ -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())));
}
}
}