summaryrefslogtreecommitdiffstats
path: root/tests/common.rs
blob: efebe173ee97cf0fc24403362d2a641d0c537c8b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#![allow(dead_code)]

pub fn init_git(temp_dir: &std::path::Path) {
    if !std::process::Command::new("git")
        .args(["init"])
        .current_dir(temp_dir)
        .status()
        .unwrap()
        .success()
    {
        panic!("Failed to git-init");
    }
}

pub fn init_cargo(temp_dir: &std::path::Path, name: &str) {
    if !std::process::Command::new("cargo")
        .args(["init", "--bin", "--name", name])
        .current_dir(temp_dir)
        .status()
        .unwrap()
        .success()
    {
        panic!("Failed to cargo-init");
    }
}

pub fn init_cargo_changelog(temp_dir: &std::path::Path) {
    assert_cmd::Command::cargo_bin("cargo-changelog")
        .unwrap()
        .args(["init"])
        .current_dir(temp_dir)
        .assert()
        .success();
}

pub fn cargo_changelog_cmd(dir: &std::path::Path) -> assert_cmd::Command {
    let mut cmd = assert_cmd::Command::cargo_bin("cargo-changelog").unwrap();
    cmd.current_dir(dir);
    cmd
}

pub fn cargo_changelog_new(dir: &std::path::Path) -> assert_cmd::Command {
    let mut cmd = cargo_changelog_cmd(dir);
    cmd.arg("new");
    cmd.arg("--interactive");
    cmd.arg("false");
    cmd.arg("--edit");
    cmd.arg("false");
    cmd
}