#[cfg(test)]
mod tests {
    use tempfile::tempdir;
    use std::fs;
    use anyhow::Result;
    use crate::project::Project;

    #[test]
    fn test_project_state_save_restore() -> Result<()> {
        let td = tempdir()?;
        let root = td.path().join("proj");
        fs::create_dir_all(&root)?;

        let mut project = Project::new(root.clone())?;
        let target = root.join("src/lib.rs");
        project.set_last_opened_file(Some(target.clone()));
        project.save_state()?;

        let mut project2 = Project::new(root.clone())?;
        project2.restore_state();
        assert_eq!(project2.last_opened_file, Some(target));
        Ok(())
    }
}
