liftoff 0.1.1

Get your coding project off the ground fast. See repo
Documentation
use liftoff::*;
use std::{
    process::Command,
    env, fs,
    path::{Path, PathBuf},
};

#[test]
fn test_cpp_config() {
    // this is done from local, not environment variables
    let current_dir = env::current_dir().unwrap();
    let file_path = PathBuf::from(&current_dir).join("files/configs/cpp.sane");

    let contents = fs::read_to_string(file_path).unwrap();
    let mut decoded_config = config::Config::new(&contents).unwrap();
    // needs to be manually set here. normally with Config::from_args
    decoded_config.project = "a_cpp_project".into();
    decoded_config.build().unwrap();

    let root = PathBuf::from(&current_dir).join(&decoded_config.project);

    // TODO check .gitignore after bliss integration
    assert!(root.exists());
    assert!(root.join("CMakeLists.txt").exists());
    assert!(root.join(".git/").exists());
    assert!(root.join(".gitignore").exists());
    assert!(root.join("README.md").exists());
    assert!(root.join("scripts").exists());
    assert!(root.join("docs").exists());
    assert!(root.join("build").exists());
    assert!(root.join("tests").join("test.cpp").exists());
    assert!(root.join("include").join("a_cpp_project").exists());
    assert!(root.join("src").join("a_cpp_project.cpp").exists());

    assert!(Path::new("/home/julian/dev/liftoff") != root);
    fs::remove_dir_all(root).unwrap();
}

#[test]
fn test_clap() {
// Can't really test clap, so this will be run as system command first
    let _output = Command::new("bash")
        .current_dir(env::current_dir().unwrap())
        .arg("tests/test_args.sh")
        .output()
        .expect("failed to execute process");

    let root = env::current_dir().unwrap().join("cpp_test_project");

    // TODO check .gitignore after bliss integration
    assert!(root.exists());
    assert!(root.join("CMakeLists.txt").exists());
    assert!(root.join(".git/").exists());
    assert!(root.join(".gitignore").exists());
    assert!(root.join("README.md").exists());
    assert!(root.join("scripts").exists());
    assert!(root.join("LICENSE").exists());
    assert!(root.join("docs").exists());
    assert!(root.join("build").exists());
    assert!(root.join("tests").join("test.cpp").exists());
    assert!(root.join("include").join("cpp_test_project").exists());
    assert!(root.join("src").join("cpp_test_project.cpp").exists());

    assert!(Path::new("/home/julian/dev/liftoff") != root);
    fs::remove_dir_all(root).unwrap();

    let root = env::current_dir().unwrap().join("cpp_test_project_no_git");

    assert!(root.exists());
    assert!(root.join("CMakeLists.txt").exists());
    assert!(!root.join(".git/").exists());
    assert!(!root.join(".gitignore").exists());
    assert!(root.join("README.md").exists());
    assert!(root.join("scripts").exists());
    assert!(root.join("LICENSE").exists());
    assert!(root.join("docs").exists());
    assert!(root.join("build").exists());
    assert!(root.join("tests").join("test.cpp").exists());
    assert!(root.join("include").join("cpp_test_project_no_git").exists());
    assert!(root.join("src").join("cpp_test_project_no_git.cpp").exists());

    assert!(Path::new("/home/julian/dev/liftoff") != root);
    fs::remove_dir_all(root).unwrap();

    let root = env::current_dir().unwrap().join("cpp_test_project_no_git_no_license");

    assert!(root.exists());
    assert!(root.join("CMakeLists.txt").exists());
    assert!(!root.join(".git/").exists());
    assert!(!root.join(".gitignore").exists());
    assert!(root.join("README.md").exists());
    assert!(root.join("scripts").exists());
    assert!(root.join("docs").exists());
    assert!(!root.join("LICENSE").exists());
    assert!(root.join("build").exists());
    assert!(root.join("tests").join("test.cpp").exists());
    assert!(root.join("include").join("cpp_test_project_no_git_no_license").exists());
    assert!(root.join("src").join("cpp_test_project_no_git_no_license.cpp").exists());

    assert!(Path::new("/home/julian/dev/liftoff") != root);
    fs::remove_dir_all(root).unwrap();
}

#[test]
fn test_python_config() {
    let current_dir = env::current_dir().unwrap();
    let file_path = PathBuf::from(&current_dir).join("files/configs/python.sane");

    let contents = fs::read_to_string(file_path).unwrap();
    let mut decoded_config = config::Config::new(&contents).unwrap();
    // needs to be manually set here. normally with Config::from_args
    decoded_config.project = "a_python_project".into();
    decoded_config.build().unwrap();

    let root = PathBuf::from(&current_dir).join(&decoded_config.project);

    assert!(root.exists());
    assert!(root.join("README.md").exists());
    assert!(root.join("requirements.txt").exists());
    assert!(root.join("setup.py").exists());
    assert!(root.join(".git/").exists());
    assert!(root.join(".gitignore").exists());
    assert!(root.join("docs").join("conf.py").exists());
    assert!(root.join("docs").join("index.rst").exists());
    assert!(root.join("tests").join("test_advanced.py").exists());
    assert!(root.join("tests").join("test_basic.py").exists());

    assert!(Path::new("/home/julian/dev/liftoff") != root);
    fs::remove_dir_all(root).unwrap();
}