use commit_crafter::git_integration;
use std::env;
#[test]
fn test_get_recent_commits() {
if env::var("GITHUB_ACTIONS").is_ok() {
eprintln!("Skipping test in GitHub Actions environment");
return;
}
let result = git_integration::get_recent_commits(3);
match result {
Ok(commits) => {
assert!(commits.len() <= 3);
for commit in commits {
assert!(!commit.is_empty());
}
}
Err(e) => {
eprintln!("Warning: Could not get recent commits: {}", e);
}
}
}
#[test]
fn test_get_recent_commits_with_zero_count() {
if env::var("GITHUB_ACTIONS").is_ok() {
eprintln!("Skipping test in GitHub Actions environment");
return;
}
let result = git_integration::get_recent_commits(0);
match result {
Ok(commits) => {
assert_eq!(commits.len(), 0);
}
Err(_) => {
}
}
}
#[test]
fn test_get_recent_commits_large_count() {
if env::var("GITHUB_ACTIONS").is_ok() {
eprintln!("Skipping test in GitHub Actions environment");
return;
}
let result = git_integration::get_recent_commits(100);
match result {
Ok(commits) => {
assert!(commits.len() <= 100);
for commit in commits {
assert!(!commit.is_empty());
}
}
Err(e) => {
eprintln!("Warning: Could not get recent commits: {}", e);
}
}
}
#[test]
fn test_run_git_diff_still_works() {
if env::var("GITHUB_ACTIONS").is_ok() {
eprintln!("Skipping test in GitHub Actions environment");
return;
}
let result = git_integration::run_git_diff();
match result {
Ok(_output) => {
assert!(true);
}
Err(e) => {
eprintln!("Git diff failed: {}", e);
}
}
}