push
github
4 of 5 new or added lines in 2 files covered. (80.0%)
1150 existing lines in 49 files now uncovered.835 of 3101 relevant lines covered (26.93%)
2.66 hits per line
1 |
use anyhow::{anyhow, Result}; |
|
2 |
use std::path::PathBuf; |
|
3 |
|
|
UNCOV
4
|
pub fn get_home() -> Result<PathBuf> { |
× |
UNCOV
5
|
home::home_dir().map_or_else(|| Err(anyhow!("Could not find home directory")), Ok)
|
× |
UNCOV
6
|
} |
× |
7 |
|
|
UNCOV
8
|
pub fn filter_fetched_keys(response: &str) -> Result<String> { |
× |
UNCOV
9
|
let mut filtered_keys = String::new();
|
× |
10 |
|
|
UNCOV
11
|
for line in response.lines() {
|
× |
UNCOV
12
|
if line.starts_with("ssh-rsa") || line.starts_with("ssh-ed25519") { |
× |
UNCOV
13
|
filtered_keys.push_str(line); |
× |
UNCOV
14
|
filtered_keys.push('\n'); // Add a newline to separate the lines |
× |
15 |
} |
|
16 |
} |
|
17 |
|
|
UNCOV
18
|
if filtered_keys.is_empty() {
|
× |
UNCOV
19
|
Err(anyhow!("No SSH keys (ssh-rsa or ssh-ed25519) found"))
|
× |
20 |
} else {
|
|
UNCOV
21
|
Ok(filtered_keys) |
× |
22 |
} |
|
UNCOV
23
|
} |
× |
24 |
|
|
25 |
#[cfg(test)]
|
|
26 |
mod tests { |
|
27 |
use super::*; |
|
28 |
|
|
29 |
#[test]
|
|
UNCOV
30
|
fn test_get_home() { |
× |
UNCOV
31
|
let home = get_home().unwrap(); |
× |
UNCOV
32
|
assert_eq!(home.is_dir(), true);
|
× |
UNCOV
33
|
} |
× |
34 |
} |