use crate::commands::Command;
use crate::services::GitService;
use crate::app::AppState;
use std::sync::Arc;
pub fn create_mock_git_service() -> Arc<GitService> {
Arc::new(GitService::new())
}
pub fn create_test_state() -> AppState {
let mut state = AppState::new();
state.repo_path = "/tmp/test-repo".to_string();
state
}
pub fn test_command_execution<T: Command>(
command: &T,
git_service: &GitService,
state: &AppState,
) -> Result<crate::commands::CommandResult, crate::errors::CommandError> {
command.execute(git_service, state)
}
#[cfg(test)]
mod tests {
use super::*;
use crate::commands::{StageFilesCommand, UnstageFilesCommand};
#[test]
fn test_stage_files_command_creation() {
let command = StageFilesCommand {
paths: vec!["test.txt".to_string()],
};
let git_service = create_mock_git_service();
let state = create_test_state();
let _result = test_command_execution(&command, &git_service, &state);
}
#[test]
fn test_unstage_files_command_creation() {
let command = UnstageFilesCommand {
paths: vec!["test.txt".to_string()],
};
let git_service = create_mock_git_service();
let state = create_test_state();
let _result = test_command_execution(&command, &git_service, &state);
}
}