refactor: Refactored the library for gman so that it dynamically names config and password files to be used across any application
This commit is contained in:
+8
-10
@@ -252,16 +252,14 @@ mod tests {
|
||||
#[test]
|
||||
fn test_config_local_provider_password_file() {
|
||||
let path = Config::local_provider_password_file();
|
||||
let expected_path = dirs::home_dir().map(|p| p.join(".gman_password"));
|
||||
if let Some(p) = &expected_path {
|
||||
if !p.exists() {
|
||||
assert_eq!(path, None);
|
||||
} else {
|
||||
assert_eq!(path, expected_path);
|
||||
}
|
||||
} else {
|
||||
assert_eq!(path, None);
|
||||
}
|
||||
// Derive expected filename based on current test executable name
|
||||
let exe = std::env::current_exe().expect("current_exe");
|
||||
let stem = exe
|
||||
.file_stem()
|
||||
.and_then(|s| s.to_str())
|
||||
.expect("utf-8 file stem");
|
||||
let expected = dirs::home_dir().map(|p| p.join(format!(".{}_password", stem)));
|
||||
assert_eq!(Some(path), expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -58,10 +58,11 @@ fn test_local_provider_invalid_email() {
|
||||
#[test]
|
||||
fn test_local_provider_default() {
|
||||
let provider = LocalProvider::default();
|
||||
assert_eq!(
|
||||
provider.password_file,
|
||||
Config::local_provider_password_file()
|
||||
);
|
||||
let expected_pw = {
|
||||
let p = Config::local_provider_password_file();
|
||||
if p.exists() { Some(p) } else { None }
|
||||
};
|
||||
assert_eq!(provider.password_file, expected_pw);
|
||||
assert_eq!(provider.git_branch, Some("main".into()));
|
||||
assert_eq!(provider.git_remote_url, None);
|
||||
assert_eq!(provider.git_user_name, None);
|
||||
|
||||
Reference in New Issue
Block a user