treeflow 0.1.9

CLI tool for simplified Git worktree management to speed up switching contexts when working collaboratively.
Documentation
#[cfg(test)]
mod utils;

#[cfg(test)]
mod init_tests {
    use crate::utils::treeflow_command::TreeflowCommand;
    use assert_cmd::Command;
    use predicates::prelude::predicate;
    use tempdir::TempDir;
    use test_case::test_case;

    #[test_case(true)]
    #[test_case(false)]
    fn init_bash_is_valid(enable_shorthands: bool) {
        let config_dir = TempDir::new("config_dir").expect("should be able to create temp config dir");

        let stdout = TreeflowCommand::new(config_dir.into_path())
            .init("bash", false)
            .cmd()
            .assert()
            .success()
            .stdout(predicate::str::starts_with("#!/usr/bin/env sh"))
            .get_output()
            .stdout
            .clone();

        let init_script = String::from_utf8(stdout).expect("should be valid UTF-8");

        if enable_shorthands {
            assert!(!init_script.contains("# Static aliases"), "Script should not contain static aliases comment when shorthands are disabled");
            assert!(!init_script.contains("# Dynamic aliases"), "Script should not contain dynamic aliases comment when shorthands are disabled");
        }

        Command::new("bash")
            .args(["-c", &format!("complete() {{ :; }}\n_complete_alias() {{ :; }}\n{}", init_script)]) // Mock the complete function for non-interactive Bash
            .assert()
            .success()
            .stdout(predicate::str::is_empty())
            .stderr(predicate::str::is_empty());
    }
}