use assert_cmd::Command;
use predicates::str::contains;
fn shipit() -> Command {
Command::cargo_bin("shipit").unwrap()
}
#[test]
fn help_exits_success() {
shipit().arg("--help").assert().success();
}
#[test]
fn help_lists_b2b_command() {
shipit()
.arg("--help")
.assert()
.stdout(contains("b2b"))
.stdout(contains("Open or apply a merge/pull request"));
}
#[test]
fn help_lists_b2t_command() {
shipit()
.arg("--help")
.assert()
.stdout(contains("b2t"))
.stdout(contains("Plan or apply an annotated tag on a branch"));
}
#[test]
fn help_lists_init_command() {
shipit()
.arg("--help")
.assert()
.stdout(contains("init"));
}
#[test]
fn help_lists_verbose_flag() {
shipit()
.arg("--help")
.assert()
.stdout(contains("--verbose"))
.stdout(contains("Increase log verbosity"));
}
#[test]
fn help_lists_version_flag() {
shipit().arg("--help").assert().stdout(contains("--version"));
}
#[test]
fn b2b_help_exits_success() {
shipit().args(["b2b", "--help"]).assert().success();
}
#[test]
fn b2b_help_lists_plan_subcommand() {
shipit()
.args(["b2b", "--help"])
.assert()
.stdout(contains("plan"))
.stdout(contains("Generate a plan file for a merge/pull request without creating it"));
}
#[test]
fn b2b_help_lists_apply_subcommand() {
shipit()
.args(["b2b", "--help"])
.assert()
.stdout(contains("apply"))
.stdout(contains("Open a merge/pull request using a plan file"));
}
#[test]
fn b2b_plan_help_exits_success() {
shipit().args(["b2b", "plan", "--help"]).assert().success();
}
#[test]
fn b2b_plan_help_lists_source_and_target_args() {
shipit()
.args(["b2b", "plan", "--help"])
.assert()
.stdout(contains("SOURCE"))
.stdout(contains("Source branch to open the merge/pull request from"))
.stdout(contains("TARGET"))
.stdout(contains("Target branch to merge into"));
}
#[test]
fn b2b_plan_help_lists_conventional_commits_flag() {
shipit()
.args(["b2b", "plan", "--help"])
.assert()
.stdout(contains("--conventional-commits"))
.stdout(contains("Categorize commits by conventional commit type"));
}
#[test]
fn b2b_plan_help_lists_title_flag() {
shipit()
.args(["b2b", "plan", "--help"])
.assert()
.stdout(contains("--title"))
.stdout(contains("Title to use for the merge/pull request"));
}
#[test]
fn b2b_plan_help_lists_description_flag() {
shipit()
.args(["b2b", "plan", "--help"])
.assert()
.stdout(contains("--description"))
.stdout(contains("Description to use for the merge/pull request"));
}
#[test]
fn b2b_plan_help_lists_yaml_flag() {
shipit()
.args(["b2b", "plan", "--help"])
.assert()
.stdout(contains("--yaml"))
.stdout(contains("Emit the plan as YAML to stdout"));
}
#[test]
fn b2b_plan_help_lists_no_sign_flag() {
shipit()
.args(["b2b", "plan", "--help"])
.assert()
.stdout(contains("--no-sign"))
.stdout(contains("Do not append the 'generated by Shipit' line"));
}
#[test]
fn b2b_plan_help_lists_only_merges_flag() {
shipit()
.args(["b2b", "plan", "--help"])
.assert()
.stdout(contains("--only-merges"))
.stdout(contains("Only include merge commits"));
}
#[test]
fn b2b_plan_help_lists_allow_dirty_flag() {
shipit()
.args(["b2b", "plan", "--help"])
.assert()
.stdout(contains("--allow-dirty"))
.stdout(contains("Continue even if the working directory has uncommitted changes"));
}
#[test]
fn b2b_plan_help_lists_yes_flag() {
shipit()
.args(["b2b", "plan", "--help"])
.assert()
.stdout(contains("--yes"))
.stdout(contains("Automatically approve all shipit command prompts"));
}
#[test]
fn b2b_apply_help_exits_success() {
shipit().args(["b2b", "apply", "--help"]).assert().success();
}
#[test]
fn b2b_apply_help_lists_plan_arg() {
shipit()
.args(["b2b", "apply", "--help"])
.assert()
.stdout(contains("PLAN"))
.stdout(contains("Name of the plan file in .shipit/plans/ to apply"));
}
#[test]
fn b2b_apply_help_lists_remote_flag() {
shipit()
.args(["b2b", "apply", "--help"])
.assert()
.stdout(contains("--remote"))
.stdout(contains("Name of the git remote to use"));
}
#[test]
fn b2b_apply_help_lists_allow_dirty_flag() {
shipit()
.args(["b2b", "apply", "--help"])
.assert()
.stdout(contains("--allow-dirty"));
}
#[test]
fn b2b_apply_help_lists_yes_flag() {
shipit()
.args(["b2b", "apply", "--help"])
.assert()
.stdout(contains("--yes"));
}
#[test]
fn b2t_help_exits_success() {
shipit().args(["b2t", "--help"]).assert().success();
}
#[test]
fn b2t_help_lists_plan_subcommand() {
shipit()
.args(["b2t", "--help"])
.assert()
.stdout(contains("plan"))
.stdout(contains("Generate a plan file for a tag without creating it"));
}
#[test]
fn b2t_help_lists_apply_subcommand() {
shipit()
.args(["b2t", "--help"])
.assert()
.stdout(contains("apply"))
.stdout(contains("Create and push a tag using a plan file"));
}
#[test]
fn b2t_plan_help_exits_success() {
shipit().args(["b2t", "plan", "--help"]).assert().success();
}
#[test]
fn b2t_plan_help_lists_branch_arg() {
shipit()
.args(["b2t", "plan", "--help"])
.assert()
.stdout(contains("BRANCH"))
.stdout(contains("Branch to create the tag on"));
}
#[test]
fn b2t_plan_help_lists_tag_arg() {
shipit()
.args(["b2t", "plan", "--help"])
.assert()
.stdout(contains("TAG"))
.stdout(contains("Name of the tag to create"));
}
#[test]
fn b2t_plan_help_lists_conventional_commits_flag() {
shipit()
.args(["b2t", "plan", "--help"])
.assert()
.stdout(contains("--conventional-commits"))
.stdout(contains("Categorize commits by conventional commit type"));
}
#[test]
fn b2t_plan_help_lists_latest_tag_flag() {
shipit()
.args(["b2t", "plan", "--help"])
.assert()
.stdout(contains("--latest-tag"))
.stdout(contains("The most recent tag to compare against"));
}
#[test]
fn b2t_plan_help_lists_description_flag() {
shipit()
.args(["b2t", "plan", "--help"])
.assert()
.stdout(contains("--description"))
.stdout(contains("Description to use for the tag notes"));
}
#[test]
fn b2t_plan_help_lists_yaml_flag() {
shipit()
.args(["b2t", "plan", "--help"])
.assert()
.stdout(contains("--yaml"))
.stdout(contains("Emit the plan as YAML to stdout"));
}
#[test]
fn b2t_plan_help_lists_no_sign_flag() {
shipit()
.args(["b2t", "plan", "--help"])
.assert()
.stdout(contains("--no-sign"))
.stdout(contains("Do not append the 'generated by Shipit' line"));
}
#[test]
fn b2t_plan_help_lists_only_merges_flag() {
shipit()
.args(["b2t", "plan", "--help"])
.assert()
.stdout(contains("--only-merges"))
.stdout(contains("Only include merge commits"));
}
#[test]
fn b2t_plan_help_lists_allow_dirty_flag() {
shipit()
.args(["b2t", "plan", "--help"])
.assert()
.stdout(contains("--allow-dirty"));
}
#[test]
fn b2t_plan_help_lists_yes_flag() {
shipit()
.args(["b2t", "plan", "--help"])
.assert()
.stdout(contains("--yes"));
}
#[test]
fn b2t_apply_help_exits_success() {
shipit().args(["b2t", "apply", "--help"]).assert().success();
}
#[test]
fn b2t_apply_help_lists_plan_arg() {
shipit()
.args(["b2t", "apply", "--help"])
.assert()
.stdout(contains("PLAN"))
.stdout(contains("Name of the plan file in .shipit/plans/ to apply"));
}
#[test]
fn b2t_apply_help_lists_remote_flag() {
shipit()
.args(["b2t", "apply", "--help"])
.assert()
.stdout(contains("--remote"))
.stdout(contains("Name of the git remote to use"));
}
#[test]
fn b2t_apply_help_lists_allow_dirty_flag() {
shipit()
.args(["b2t", "apply", "--help"])
.assert()
.stdout(contains("--allow-dirty"));
}
#[test]
fn b2t_apply_help_lists_yes_flag() {
shipit()
.args(["b2t", "apply", "--help"])
.assert()
.stdout(contains("--yes"));
}
#[test]
fn init_help_exits_success() {
shipit().args(["init", "--help"]).assert().success();
}
#[test]
fn init_help_lists_dir_flag() {
shipit()
.args(["init", "--help"])
.assert()
.stdout(contains("--dir"))
.stdout(contains("Directory to write the config file to"));
}
#[test]
fn init_help_lists_platform_token_flag() {
shipit()
.args(["init", "--help"])
.assert()
.stdout(contains("--platform-token"))
.stdout(contains("Platform personal access token"));
}
#[test]
fn init_help_lists_platform_domain_flag() {
shipit()
.args(["init", "--help"])
.assert()
.stdout(contains("--platform-domain"))
.stdout(contains("Platform domain"));
}
#[test]
fn claude_help_exits_success() {
shipit()
.args(["claude", "--help"])
.assert()
.success();
}
#[test]
fn help_lists_claude_command() {
shipit()
.arg("--help")
.assert()
.stdout(contains("claude"));
}
#[test]
fn init_help_lists_remote_flag() {
shipit()
.args(["init", "--help"])
.assert()
.stdout(contains("--remote"))
.stdout(contains("Git remote to infer the platform domain from"));
}