diff --git a/tests/test_git.rs b/tests/test_git.rs index 33563ab..67b457e 100644 --- a/tests/test_git.rs +++ b/tests/test_git.rs @@ -5,7 +5,7 @@ mod git { use std::{fs::remove_dir_all, path::Path}; - use busser::{config::GitConfig, integrations::git::from_clone}; + use busser::{config::{GitAuthConfig, GitConfig}, integrations::git::from_clone}; #[test] pub fn test_clone() @@ -17,15 +17,68 @@ mod git auth: None, }; - let repo = from_clone("tests/test-repo".into(), &config); + let path = "tests/test_clone"; + let repo = from_clone(path.into(), &config); - assert!(!repo.as_ref().unwrap().is_empty().unwrap()); assert!(repo.is_ok()); - assert!(Path::exists(Path::new("tests/test-repo"))); + assert!(!repo.as_ref().unwrap().is_empty().unwrap()); + assert!(Path::exists(Path::new(path))); + + if Path::exists(Path::new(path)) + { + let _ = remove_dir_all(Path::new(path)); + } + } + + #[test] + pub fn test_key_authed_clone() + { + let config = GitConfig + { + remote: "https://github.com/JerboaBurrow/test".into(), + branch: "main".into(), + auth: Some(GitAuthConfig + { + key_path: Some("not_a_key".into()), + user: "not_a_user".into(), + passphrase: "not_a_passphrase".into(), + }), + }; + + let path = "tests/test_key_authed_clone"; + let repo = from_clone(path.into(), &config); + + assert!(repo.is_err()); + + if Path::exists(Path::new(path)) + { + let _ = remove_dir_all(Path::new(path)); + } + } + + #[test] + pub fn test_pass_authed_clone() + { + let config = GitConfig + { + remote: "https://github.com/JerboaBurrow/test".into(), + branch: "main".into(), + auth: Some(GitAuthConfig + { + key_path: None, + user: "not_a_user".into(), + passphrase: "not_a_passphrase".into(), + }), + }; + + let path = "tests/test_pass_authed_clone"; + let repo = from_clone(path.into(), &config); + + assert!(repo.is_err()); - if Path::exists(Path::new("tests/test-repo")) + if Path::exists(Path::new(path)) { - let _ = remove_dir_all(Path::new("tests/test-repo")); + let _ = remove_dir_all(Path::new(path)); } } } \ No newline at end of file