use super::id::ChangeId;
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct WorkspaceInfo {
pub name: String,
pub root_path: Option<String>,
pub change_id: ChangeId,
pub description: String,
}
impl WorkspaceInfo {
pub fn is_default(&self) -> bool {
self.name == "default"
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_is_default() {
let ws = WorkspaceInfo {
name: "default".into(),
root_path: Some("/tmp/repo".into()),
change_id: ChangeId::from("ltyxkzyp"),
description: "(no description set)".into(),
};
assert!(ws.is_default());
}
#[test]
fn test_not_default() {
let ws = WorkspaceInfo {
name: "feature-a".into(),
root_path: Some("/tmp/feature-ws".into()),
change_id: ChangeId::from("xyzpqrst"),
description: "implement feature A".into(),
};
assert!(!ws.is_default());
}
}