use knotra_vcs::{ProjectConflictDetail, ProjectId};
use std::collections::HashMap;
#[derive(Debug, Clone, Default)]
#[allow(dead_code)]
pub enum ConflictPhase {
#[default]
Idle,
Loading(ProjectId),
Browsing {
project_id: ProjectId,
detail: ProjectConflictDetail,
},
Operating { project_id: ProjectId, action: String },
Done { project_id: ProjectId, success: bool, message: String },
}
#[derive(Debug, Default)]
pub struct ConflictOpsState {
pub phase: ConflictPhase,
pub cached: HashMap<ProjectId, ProjectConflictDetail>,
}
#[cfg(test)]
mod tests {
use knotra_vcs::{ConflictedFile, ConflictMarker, ProjectConflictDetail, ProjectId};
#[test]
fn conflict_detail_resolved_when_no_files() {
let detail = ProjectConflictDetail {
project_id: ProjectId::new(),
project_name: "svc".to_owned(),
conflicted_files: vec![],
note: None,
read_error: None,
};
assert!(detail.is_resolved());
}
#[test]
fn conflict_detail_not_resolved_with_files() {
let detail = ProjectConflictDetail {
project_id: ProjectId::new(),
project_name: "svc".to_owned(),
conflicted_files: vec![ConflictedFile {
path: "src/lib.rs".to_owned(),
marker: ConflictMarker::BothModified,
}],
note: None,
read_error: None,
};
assert!(!detail.is_resolved());
assert_eq!(detail.file_count(), 1);
}
}