Skip to content

Commit

Permalink
test fake creds
Browse files Browse the repository at this point in the history
  • Loading branch information
Jerboa-app committed May 29, 2024
1 parent 5bdceb6 commit 6ef90b5
Showing 1 changed file with 59 additions and 6 deletions.
65 changes: 59 additions & 6 deletions tests/test_git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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));
}
}
}

0 comments on commit 6ef90b5

Please sign in to comment.