Initial upload: GitPulse - Developer Productivity Analyzer CLI tool
Some checks failed
CI / test (push) Has been cancelled
CI / release (push) Has been cancelled

This commit is contained in:
2026-02-04 15:45:50 +00:00
parent bdf1bd96cd
commit 4aaaf7c3e0

54
tests/models_test.rs Normal file
View File

@@ -0,0 +1,54 @@
#[cfg(test)]
mod tests {
use crate::models::{AuthorStats, CommitFrequency, RepositoryInfo};
use serde_json;
#[test]
fn test_author_stats_serde() {
let stats = AuthorStats {
name: "Test User".to_string(),
email: "test@example.com".to_string(),
commits: 10,
lines_added: 100,
lines_removed: 50,
net_change: 50,
files_changed: 5,
first_commit: "2024-01-01T00:00:00Z".to_string(),
last_commit: "2024-01-15T00:00:00Z".to_string(),
active_days: 5,
average_commits_per_day: 2.0,
busiest_day: "Monday".to_string(),
busiest_day_count: 5,
commit_messages: vec!["feat: add feature".to_string()],
};
let json = serde_json::to_string(&stats).unwrap();
let deserialized: AuthorStats = serde_json::from_str(&json).unwrap();
assert_eq!(deserialized.name, stats.name);
assert_eq!(deserialized.commits, stats.commits);
}
#[test]
fn test_repository_info_serde() {
let info = RepositoryInfo {
path: "/test/repo".to_string(),
branch: Some("main".to_string()),
remote_url: Some("https://github.com/test/repo".to_string()),
total_commits: 100,
total_authors: 5,
repository_age_days: 365,
};
let json = serde_json::to_string(&info).unwrap();
let deserialized: RepositoryInfo = serde_json::from_str(&json).unwrap();
assert_eq!(deserialized.path, info.path);
assert_eq!(deserialized.total_commits, info.total_commits);
}
#[test]
fn test_commit_frequency_defaults() {
let freq = CommitFrequency::default();
assert_eq!(freq.total_commits, 0);
assert_eq!(freq.commits_per_day, 0.0);
}
}