style: 格式化代码并优化导入顺序
This commit is contained in:
@@ -20,7 +20,12 @@ mod config_export {
|
||||
init_quicommit(&config_path);
|
||||
|
||||
let mut cmd = cargo_bin_cmd!("quicommit");
|
||||
cmd.args(&["config", "export", "--config", config_path.to_str().unwrap()]);
|
||||
cmd.args(&[
|
||||
"config",
|
||||
"export",
|
||||
"--config",
|
||||
config_path.to_str().unwrap(),
|
||||
]);
|
||||
|
||||
cmd.assert()
|
||||
.success()
|
||||
@@ -37,10 +42,14 @@ mod config_export {
|
||||
|
||||
let mut cmd = cargo_bin_cmd!("quicommit");
|
||||
cmd.args(&[
|
||||
"config", "export",
|
||||
"--config", config_path.to_str().unwrap(),
|
||||
"--output", export_path.to_str().unwrap(),
|
||||
"--password", ""
|
||||
"config",
|
||||
"export",
|
||||
"--config",
|
||||
config_path.to_str().unwrap(),
|
||||
"--output",
|
||||
export_path.to_str().unwrap(),
|
||||
"--password",
|
||||
"",
|
||||
]);
|
||||
|
||||
cmd.assert()
|
||||
@@ -48,10 +57,13 @@ mod config_export {
|
||||
.stdout(predicate::str::contains("Configuration exported"));
|
||||
|
||||
assert!(export_path.exists(), "Export file should be created");
|
||||
|
||||
|
||||
let content = fs::read_to_string(&export_path).unwrap();
|
||||
assert!(content.contains("version"), "Export should contain version");
|
||||
assert!(content.contains("[llm]"), "Export should contain LLM config");
|
||||
assert!(
|
||||
content.contains("[llm]"),
|
||||
"Export should contain LLM config"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -63,10 +75,14 @@ mod config_export {
|
||||
|
||||
let mut cmd = cargo_bin_cmd!("quicommit");
|
||||
cmd.args(&[
|
||||
"config", "export",
|
||||
"--config", config_path.to_str().unwrap(),
|
||||
"--output", export_path.to_str().unwrap(),
|
||||
"--password", "test_password_123"
|
||||
"config",
|
||||
"export",
|
||||
"--config",
|
||||
config_path.to_str().unwrap(),
|
||||
"--output",
|
||||
export_path.to_str().unwrap(),
|
||||
"--password",
|
||||
"test_password_123",
|
||||
]);
|
||||
|
||||
cmd.assert()
|
||||
@@ -74,10 +90,16 @@ mod config_export {
|
||||
.stdout(predicate::str::contains("encrypted and exported"));
|
||||
|
||||
assert!(export_path.exists(), "Export file should be created");
|
||||
|
||||
|
||||
let content = fs::read_to_string(&export_path).unwrap();
|
||||
assert!(content.starts_with("ENCRYPTED:"), "Encrypted file should start with ENCRYPTED:");
|
||||
assert!(!content.contains("[llm]"), "Encrypted content should not be readable");
|
||||
assert!(
|
||||
content.starts_with("ENCRYPTED:"),
|
||||
"Encrypted file should start with ENCRYPTED:"
|
||||
);
|
||||
assert!(
|
||||
!content.contains("[llm]"),
|
||||
"Encrypted content should not be readable"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,7 +111,7 @@ mod config_import {
|
||||
let temp_dir = TempDir::new().unwrap();
|
||||
let config_path = temp_dir.path().join("config.toml");
|
||||
let import_path = temp_dir.path().join("import.toml");
|
||||
|
||||
|
||||
let plain_config = r#"
|
||||
version = "1"
|
||||
|
||||
@@ -139,9 +161,12 @@ keep_changelog_types_english = true
|
||||
|
||||
let mut cmd = cargo_bin_cmd!("quicommit");
|
||||
cmd.args(&[
|
||||
"config", "import",
|
||||
"--config", config_path.to_str().unwrap(),
|
||||
"--file", import_path.to_str().unwrap()
|
||||
"config",
|
||||
"import",
|
||||
"--config",
|
||||
config_path.to_str().unwrap(),
|
||||
"--file",
|
||||
import_path.to_str().unwrap(),
|
||||
]);
|
||||
|
||||
cmd.assert()
|
||||
@@ -149,7 +174,13 @@ keep_changelog_types_english = true
|
||||
.stdout(predicate::str::contains("Configuration imported"));
|
||||
|
||||
let mut cmd = cargo_bin_cmd!("quicommit");
|
||||
cmd.args(&["config", "get", "llm.provider", "--config", config_path.to_str().unwrap()]);
|
||||
cmd.args(&[
|
||||
"config",
|
||||
"get",
|
||||
"llm.provider",
|
||||
"--config",
|
||||
config_path.to_str().unwrap(),
|
||||
]);
|
||||
cmd.assert()
|
||||
.success()
|
||||
.stdout(predicate::str::contains("openai"));
|
||||
@@ -161,38 +192,56 @@ keep_changelog_types_english = true
|
||||
let config_path1 = temp_dir.path().join("config1.toml");
|
||||
let config_path2 = temp_dir.path().join("config2.toml");
|
||||
let export_path = temp_dir.path().join("encrypted.toml");
|
||||
|
||||
|
||||
init_quicommit(&config_path1);
|
||||
|
||||
let mut cmd = cargo_bin_cmd!("quicommit");
|
||||
cmd.args(&[
|
||||
"config", "set", "llm.provider", "anthropic",
|
||||
"--config", config_path1.to_str().unwrap()
|
||||
"config",
|
||||
"set",
|
||||
"llm.provider",
|
||||
"anthropic",
|
||||
"--config",
|
||||
config_path1.to_str().unwrap(),
|
||||
]);
|
||||
cmd.assert().success();
|
||||
|
||||
let mut cmd = cargo_bin_cmd!("quicommit");
|
||||
cmd.args(&[
|
||||
"config", "export",
|
||||
"--config", config_path1.to_str().unwrap(),
|
||||
"--output", export_path.to_str().unwrap(),
|
||||
"--password", "secure_password"
|
||||
"config",
|
||||
"export",
|
||||
"--config",
|
||||
config_path1.to_str().unwrap(),
|
||||
"--output",
|
||||
export_path.to_str().unwrap(),
|
||||
"--password",
|
||||
"secure_password",
|
||||
]);
|
||||
cmd.assert().success();
|
||||
|
||||
let mut cmd = cargo_bin_cmd!("quicommit");
|
||||
cmd.args(&[
|
||||
"config", "import",
|
||||
"--config", config_path2.to_str().unwrap(),
|
||||
"--file", export_path.to_str().unwrap(),
|
||||
"--password", "secure_password"
|
||||
"config",
|
||||
"import",
|
||||
"--config",
|
||||
config_path2.to_str().unwrap(),
|
||||
"--file",
|
||||
export_path.to_str().unwrap(),
|
||||
"--password",
|
||||
"secure_password",
|
||||
]);
|
||||
cmd.assert()
|
||||
.success()
|
||||
.stdout(predicate::str::contains("Configuration imported"));
|
||||
|
||||
let mut cmd = cargo_bin_cmd!("quicommit");
|
||||
cmd.args(&["config", "get", "llm.provider", "--config", config_path2.to_str().unwrap()]);
|
||||
cmd.args(&[
|
||||
"config",
|
||||
"get",
|
||||
"llm.provider",
|
||||
"--config",
|
||||
config_path2.to_str().unwrap(),
|
||||
]);
|
||||
cmd.assert()
|
||||
.success()
|
||||
.stdout(predicate::str::contains("anthropic"));
|
||||
@@ -203,24 +252,32 @@ keep_changelog_types_english = true
|
||||
let temp_dir = TempDir::new().unwrap();
|
||||
let config_path = temp_dir.path().join("config.toml");
|
||||
let export_path = temp_dir.path().join("encrypted.toml");
|
||||
|
||||
|
||||
init_quicommit(&config_path);
|
||||
|
||||
let mut cmd = cargo_bin_cmd!("quicommit");
|
||||
cmd.args(&[
|
||||
"config", "export",
|
||||
"--config", config_path.to_str().unwrap(),
|
||||
"--output", export_path.to_str().unwrap(),
|
||||
"--password", "correct_password"
|
||||
"config",
|
||||
"export",
|
||||
"--config",
|
||||
config_path.to_str().unwrap(),
|
||||
"--output",
|
||||
export_path.to_str().unwrap(),
|
||||
"--password",
|
||||
"correct_password",
|
||||
]);
|
||||
cmd.assert().success();
|
||||
|
||||
let mut cmd = cargo_bin_cmd!("quicommit");
|
||||
cmd.args(&[
|
||||
"config", "import",
|
||||
"--config", config_path.to_str().unwrap(),
|
||||
"--file", export_path.to_str().unwrap(),
|
||||
"--password", "wrong_password"
|
||||
"config",
|
||||
"import",
|
||||
"--config",
|
||||
config_path.to_str().unwrap(),
|
||||
"--file",
|
||||
export_path.to_str().unwrap(),
|
||||
"--password",
|
||||
"wrong_password",
|
||||
]);
|
||||
cmd.assert()
|
||||
.failure()
|
||||
@@ -237,35 +294,52 @@ mod config_export_import_roundtrip {
|
||||
let config_path1 = temp_dir.path().join("config1.toml");
|
||||
let config_path2 = temp_dir.path().join("config2.toml");
|
||||
let export_path = temp_dir.path().join("export.toml");
|
||||
|
||||
|
||||
init_quicommit(&config_path1);
|
||||
|
||||
let mut cmd = cargo_bin_cmd!("quicommit");
|
||||
cmd.args(&[
|
||||
"config", "set", "llm.model", "gpt-4-turbo",
|
||||
"--config", config_path1.to_str().unwrap()
|
||||
"config",
|
||||
"set",
|
||||
"llm.model",
|
||||
"gpt-4-turbo",
|
||||
"--config",
|
||||
config_path1.to_str().unwrap(),
|
||||
]);
|
||||
cmd.assert().success();
|
||||
|
||||
let mut cmd = cargo_bin_cmd!("quicommit");
|
||||
cmd.args(&[
|
||||
"config", "export",
|
||||
"--config", config_path1.to_str().unwrap(),
|
||||
"--output", export_path.to_str().unwrap(),
|
||||
"--password", ""
|
||||
"config",
|
||||
"export",
|
||||
"--config",
|
||||
config_path1.to_str().unwrap(),
|
||||
"--output",
|
||||
export_path.to_str().unwrap(),
|
||||
"--password",
|
||||
"",
|
||||
]);
|
||||
cmd.assert().success();
|
||||
|
||||
let mut cmd = cargo_bin_cmd!("quicommit");
|
||||
cmd.args(&[
|
||||
"config", "import",
|
||||
"--config", config_path2.to_str().unwrap(),
|
||||
"--file", export_path.to_str().unwrap()
|
||||
"config",
|
||||
"import",
|
||||
"--config",
|
||||
config_path2.to_str().unwrap(),
|
||||
"--file",
|
||||
export_path.to_str().unwrap(),
|
||||
]);
|
||||
cmd.assert().success();
|
||||
|
||||
let mut cmd = cargo_bin_cmd!("quicommit");
|
||||
cmd.args(&["config", "get", "llm.model", "--config", config_path2.to_str().unwrap()]);
|
||||
cmd.args(&[
|
||||
"config",
|
||||
"get",
|
||||
"llm.model",
|
||||
"--config",
|
||||
config_path2.to_str().unwrap(),
|
||||
]);
|
||||
cmd.assert()
|
||||
.success()
|
||||
.stdout(predicate::str::contains("gpt-4-turbo"));
|
||||
@@ -278,29 +352,41 @@ mod config_export_import_roundtrip {
|
||||
let config_path2 = temp_dir.path().join("config2.toml");
|
||||
let export_path = temp_dir.path().join("encrypted.toml");
|
||||
let password = "my_secure_password_123";
|
||||
|
||||
|
||||
init_quicommit(&config_path1);
|
||||
|
||||
let mut cmd = cargo_bin_cmd!("quicommit");
|
||||
cmd.args(&[
|
||||
"config", "set", "llm.provider", "deepseek",
|
||||
"--config", config_path1.to_str().unwrap()
|
||||
"config",
|
||||
"set",
|
||||
"llm.provider",
|
||||
"deepseek",
|
||||
"--config",
|
||||
config_path1.to_str().unwrap(),
|
||||
]);
|
||||
cmd.assert().success();
|
||||
|
||||
let mut cmd = cargo_bin_cmd!("quicommit");
|
||||
cmd.args(&[
|
||||
"config", "set", "llm.model", "deepseek-chat",
|
||||
"--config", config_path1.to_str().unwrap()
|
||||
"config",
|
||||
"set",
|
||||
"llm.model",
|
||||
"deepseek-chat",
|
||||
"--config",
|
||||
config_path1.to_str().unwrap(),
|
||||
]);
|
||||
cmd.assert().success();
|
||||
|
||||
let mut cmd = cargo_bin_cmd!("quicommit");
|
||||
cmd.args(&[
|
||||
"config", "export",
|
||||
"--config", config_path1.to_str().unwrap(),
|
||||
"--output", export_path.to_str().unwrap(),
|
||||
"--password", password
|
||||
"config",
|
||||
"export",
|
||||
"--config",
|
||||
config_path1.to_str().unwrap(),
|
||||
"--output",
|
||||
export_path.to_str().unwrap(),
|
||||
"--password",
|
||||
password,
|
||||
]);
|
||||
cmd.assert().success();
|
||||
|
||||
@@ -310,21 +396,37 @@ mod config_export_import_roundtrip {
|
||||
|
||||
let mut cmd = cargo_bin_cmd!("quicommit");
|
||||
cmd.args(&[
|
||||
"config", "import",
|
||||
"--config", config_path2.to_str().unwrap(),
|
||||
"--file", export_path.to_str().unwrap(),
|
||||
"--password", password
|
||||
"config",
|
||||
"import",
|
||||
"--config",
|
||||
config_path2.to_str().unwrap(),
|
||||
"--file",
|
||||
export_path.to_str().unwrap(),
|
||||
"--password",
|
||||
password,
|
||||
]);
|
||||
cmd.assert().success();
|
||||
|
||||
let mut cmd = cargo_bin_cmd!("quicommit");
|
||||
cmd.args(&["config", "get", "llm.provider", "--config", config_path2.to_str().unwrap()]);
|
||||
cmd.args(&[
|
||||
"config",
|
||||
"get",
|
||||
"llm.provider",
|
||||
"--config",
|
||||
config_path2.to_str().unwrap(),
|
||||
]);
|
||||
cmd.assert()
|
||||
.success()
|
||||
.stdout(predicate::str::contains("deepseek"));
|
||||
|
||||
let mut cmd = cargo_bin_cmd!("quicommit");
|
||||
cmd.args(&["config", "get", "llm.model", "--config", config_path2.to_str().unwrap()]);
|
||||
cmd.args(&[
|
||||
"config",
|
||||
"get",
|
||||
"llm.model",
|
||||
"--config",
|
||||
config_path2.to_str().unwrap(),
|
||||
]);
|
||||
cmd.assert()
|
||||
.success()
|
||||
.stdout(predicate::str::contains("deepseek-chat"));
|
||||
|
||||
@@ -107,8 +107,14 @@ mod cli_basic {
|
||||
configure_git_user(&repo_path);
|
||||
|
||||
let mut cmd = cargo_bin_cmd!("quicommit");
|
||||
cmd.args(&["-vv", "init", "--yes", "--config", config_path.to_str().unwrap()])
|
||||
.current_dir(&repo_path);
|
||||
cmd.args(&[
|
||||
"-vv",
|
||||
"init",
|
||||
"--yes",
|
||||
"--config",
|
||||
config_path.to_str().unwrap(),
|
||||
])
|
||||
.current_dir(&repo_path);
|
||||
|
||||
cmd.assert().success();
|
||||
}
|
||||
@@ -169,7 +175,13 @@ mod init_command {
|
||||
cmd.assert().success();
|
||||
|
||||
let mut cmd = cargo_bin_cmd!("quicommit");
|
||||
cmd.args(&["init", "--yes", "--reset", "--config", config_path.to_str().unwrap()]);
|
||||
cmd.args(&[
|
||||
"init",
|
||||
"--yes",
|
||||
"--reset",
|
||||
"--config",
|
||||
config_path.to_str().unwrap(),
|
||||
]);
|
||||
cmd.assert()
|
||||
.success()
|
||||
.stdout(predicate::str::contains("initialized successfully"));
|
||||
@@ -261,8 +273,14 @@ mod commit_command {
|
||||
cmd.assert().success();
|
||||
|
||||
let mut cmd = cargo_bin_cmd!("quicommit");
|
||||
cmd.args(&["commit", "--dry-run", "--yes", "--config", config_path.to_str().unwrap()])
|
||||
.current_dir(temp_dir.path());
|
||||
cmd.args(&[
|
||||
"commit",
|
||||
"--dry-run",
|
||||
"--yes",
|
||||
"--config",
|
||||
config_path.to_str().unwrap(),
|
||||
])
|
||||
.current_dir(temp_dir.path());
|
||||
|
||||
cmd.assert()
|
||||
.failure()
|
||||
@@ -279,8 +297,17 @@ mod commit_command {
|
||||
init_quicommit(&repo_path, &config_path);
|
||||
|
||||
let mut cmd = cargo_bin_cmd!("quicommit");
|
||||
cmd.args(&["commit", "--manual", "-m", "test: empty", "--dry-run", "--yes", "--config", config_path.to_str().unwrap()])
|
||||
.current_dir(&repo_path);
|
||||
cmd.args(&[
|
||||
"commit",
|
||||
"--manual",
|
||||
"-m",
|
||||
"test: empty",
|
||||
"--dry-run",
|
||||
"--yes",
|
||||
"--config",
|
||||
config_path.to_str().unwrap(),
|
||||
])
|
||||
.current_dir(&repo_path);
|
||||
|
||||
cmd.assert()
|
||||
.success()
|
||||
@@ -297,8 +324,17 @@ mod commit_command {
|
||||
init_quicommit(&repo_path, &config_path);
|
||||
|
||||
let mut cmd = cargo_bin_cmd!("quicommit");
|
||||
cmd.args(&["commit", "--manual", "-m", "test: add test file", "--dry-run", "--yes", "--config", config_path.to_str().unwrap()])
|
||||
.current_dir(&repo_path);
|
||||
cmd.args(&[
|
||||
"commit",
|
||||
"--manual",
|
||||
"-m",
|
||||
"test: add test file",
|
||||
"--dry-run",
|
||||
"--yes",
|
||||
"--config",
|
||||
config_path.to_str().unwrap(),
|
||||
])
|
||||
.current_dir(&repo_path);
|
||||
|
||||
cmd.assert()
|
||||
.success()
|
||||
@@ -315,8 +351,15 @@ mod commit_command {
|
||||
init_quicommit(&repo_path, &config_path);
|
||||
|
||||
let mut cmd = cargo_bin_cmd!("quicommit");
|
||||
cmd.args(&["commit", "--date", "--dry-run", "--yes", "--config", config_path.to_str().unwrap()])
|
||||
.current_dir(&repo_path);
|
||||
cmd.args(&[
|
||||
"commit",
|
||||
"--date",
|
||||
"--dry-run",
|
||||
"--yes",
|
||||
"--config",
|
||||
config_path.to_str().unwrap(),
|
||||
])
|
||||
.current_dir(&repo_path);
|
||||
|
||||
cmd.assert()
|
||||
.success()
|
||||
@@ -333,8 +376,18 @@ mod commit_command {
|
||||
init_quicommit(&repo_path, &config_path);
|
||||
|
||||
let mut cmd = cargo_bin_cmd!("quicommit");
|
||||
cmd.args(&["commit", "--think", "--manual", "-m", "test: think flag", "--dry-run", "--yes", "--config", config_path.to_str().unwrap()])
|
||||
.current_dir(&repo_path);
|
||||
cmd.args(&[
|
||||
"commit",
|
||||
"--think",
|
||||
"--manual",
|
||||
"-m",
|
||||
"test: think flag",
|
||||
"--dry-run",
|
||||
"--yes",
|
||||
"--config",
|
||||
config_path.to_str().unwrap(),
|
||||
])
|
||||
.current_dir(&repo_path);
|
||||
|
||||
cmd.assert().success();
|
||||
}
|
||||
@@ -353,8 +406,14 @@ mod tag_command {
|
||||
cmd.assert().success();
|
||||
|
||||
let mut cmd = cargo_bin_cmd!("quicommit");
|
||||
cmd.args(&["tag", "--dry-run", "--yes", "--config", config_path.to_str().unwrap()])
|
||||
.current_dir(temp_dir.path());
|
||||
cmd.args(&[
|
||||
"tag",
|
||||
"--dry-run",
|
||||
"--yes",
|
||||
"--config",
|
||||
config_path.to_str().unwrap(),
|
||||
])
|
||||
.current_dir(temp_dir.path());
|
||||
|
||||
cmd.assert()
|
||||
.failure()
|
||||
@@ -375,8 +434,16 @@ mod tag_command {
|
||||
init_quicommit(&repo_path, &config_path);
|
||||
|
||||
let mut cmd = cargo_bin_cmd!("quicommit");
|
||||
cmd.args(&["tag", "--name", "v0.1.0", "--dry-run", "--yes", "--config", config_path.to_str().unwrap()])
|
||||
.current_dir(&repo_path);
|
||||
cmd.args(&[
|
||||
"tag",
|
||||
"--name",
|
||||
"v0.1.0",
|
||||
"--dry-run",
|
||||
"--yes",
|
||||
"--config",
|
||||
config_path.to_str().unwrap(),
|
||||
])
|
||||
.current_dir(&repo_path);
|
||||
|
||||
cmd.assert()
|
||||
.success()
|
||||
@@ -397,8 +464,17 @@ mod tag_command {
|
||||
init_quicommit(&repo_path, &config_path);
|
||||
|
||||
let mut cmd = cargo_bin_cmd!("quicommit");
|
||||
cmd.args(&["tag", "--think", "--name", "v0.2.0", "--dry-run", "--yes", "--config", config_path.to_str().unwrap()])
|
||||
.current_dir(&repo_path);
|
||||
cmd.args(&[
|
||||
"tag",
|
||||
"--think",
|
||||
"--name",
|
||||
"v0.2.0",
|
||||
"--dry-run",
|
||||
"--yes",
|
||||
"--config",
|
||||
config_path.to_str().unwrap(),
|
||||
])
|
||||
.current_dir(&repo_path);
|
||||
|
||||
cmd.assert().success();
|
||||
}
|
||||
@@ -419,8 +495,15 @@ mod changelog_command {
|
||||
init_quicommit(&repo_path, &config_path);
|
||||
|
||||
let mut cmd = cargo_bin_cmd!("quicommit");
|
||||
cmd.args(&["changelog", "--init", "--output", changelog_path.to_str().unwrap(), "--config", config_path.to_str().unwrap()])
|
||||
.current_dir(&repo_path);
|
||||
cmd.args(&[
|
||||
"changelog",
|
||||
"--init",
|
||||
"--output",
|
||||
changelog_path.to_str().unwrap(),
|
||||
"--config",
|
||||
config_path.to_str().unwrap(),
|
||||
])
|
||||
.current_dir(&repo_path);
|
||||
|
||||
cmd.assert().success();
|
||||
|
||||
@@ -441,11 +524,16 @@ mod changelog_command {
|
||||
init_quicommit(&repo_path, &config_path);
|
||||
|
||||
let mut cmd = cargo_bin_cmd!("quicommit");
|
||||
cmd.args(&["changelog", "--dry-run", "--yes", "--config", config_path.to_str().unwrap()])
|
||||
.current_dir(&repo_path);
|
||||
cmd.args(&[
|
||||
"changelog",
|
||||
"--dry-run",
|
||||
"--yes",
|
||||
"--config",
|
||||
config_path.to_str().unwrap(),
|
||||
])
|
||||
.current_dir(&repo_path);
|
||||
|
||||
cmd.assert()
|
||||
.success();
|
||||
cmd.assert().success();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -560,8 +648,17 @@ mod validators {
|
||||
init_quicommit(&repo_path, &config_path);
|
||||
|
||||
let mut cmd = cargo_bin_cmd!("quicommit");
|
||||
cmd.args(&["commit", "--manual", "-m", "invalid commit message without type", "--dry-run", "--yes", "--config", config_path.to_str().unwrap()])
|
||||
.current_dir(&repo_path);
|
||||
cmd.args(&[
|
||||
"commit",
|
||||
"--manual",
|
||||
"-m",
|
||||
"invalid commit message without type",
|
||||
"--dry-run",
|
||||
"--yes",
|
||||
"--config",
|
||||
config_path.to_str().unwrap(),
|
||||
])
|
||||
.current_dir(&repo_path);
|
||||
|
||||
cmd.assert()
|
||||
.failure()
|
||||
@@ -578,8 +675,17 @@ mod validators {
|
||||
init_quicommit(&repo_path, &config_path);
|
||||
|
||||
let mut cmd = cargo_bin_cmd!("quicommit");
|
||||
cmd.args(&["commit", "--manual", "-m", "feat: add new feature", "--dry-run", "--yes", "--config", config_path.to_str().unwrap()])
|
||||
.current_dir(&repo_path);
|
||||
cmd.args(&[
|
||||
"commit",
|
||||
"--manual",
|
||||
"-m",
|
||||
"feat: add new feature",
|
||||
"--dry-run",
|
||||
"--yes",
|
||||
"--config",
|
||||
config_path.to_str().unwrap(),
|
||||
])
|
||||
.current_dir(&repo_path);
|
||||
|
||||
cmd.assert()
|
||||
.success()
|
||||
@@ -600,8 +706,17 @@ mod subcommands {
|
||||
init_quicommit(&repo_path, &config_path);
|
||||
|
||||
let mut cmd = cargo_bin_cmd!("quicommit");
|
||||
cmd.args(&["c", "--manual", "-m", "fix: test", "--dry-run", "--yes", "--config", config_path.to_str().unwrap()])
|
||||
.current_dir(&repo_path);
|
||||
cmd.args(&[
|
||||
"c",
|
||||
"--manual",
|
||||
"-m",
|
||||
"fix: test",
|
||||
"--dry-run",
|
||||
"--yes",
|
||||
"--config",
|
||||
config_path.to_str().unwrap(),
|
||||
])
|
||||
.current_dir(&repo_path);
|
||||
|
||||
cmd.assert()
|
||||
.success()
|
||||
@@ -648,7 +763,12 @@ mod edge_cases {
|
||||
let non_existent_config = temp_dir.path().join("non_existent_config.toml");
|
||||
|
||||
let mut cmd = cargo_bin_cmd!("quicommit");
|
||||
cmd.args(&["config", "show", "--config", non_existent_config.to_str().unwrap()]);
|
||||
cmd.args(&[
|
||||
"config",
|
||||
"show",
|
||||
"--config",
|
||||
non_existent_config.to_str().unwrap(),
|
||||
]);
|
||||
|
||||
cmd.assert()
|
||||
.success()
|
||||
@@ -668,8 +788,14 @@ mod edge_cases {
|
||||
cmd.assert().success();
|
||||
|
||||
let mut cmd = cargo_bin_cmd!("quicommit");
|
||||
cmd.args(&["commit", "--dry-run", "--yes", "--config", config_path.to_str().unwrap()])
|
||||
.current_dir(&repo_path);
|
||||
cmd.args(&[
|
||||
"commit",
|
||||
"--dry-run",
|
||||
"--yes",
|
||||
"--config",
|
||||
config_path.to_str().unwrap(),
|
||||
])
|
||||
.current_dir(&repo_path);
|
||||
|
||||
cmd.assert()
|
||||
.failure()
|
||||
@@ -686,11 +812,20 @@ mod edge_cases {
|
||||
init_quicommit(&repo_path, &config_path);
|
||||
|
||||
let mut cmd = cargo_bin_cmd!("quicommit");
|
||||
cmd.args(&["commit", "--manual", "-m", "", "--dry-run", "--yes", "--config", config_path.to_str().unwrap()])
|
||||
.current_dir(&repo_path);
|
||||
cmd.args(&[
|
||||
"commit",
|
||||
"--manual",
|
||||
"-m",
|
||||
"",
|
||||
"--dry-run",
|
||||
"--yes",
|
||||
"--config",
|
||||
config_path.to_str().unwrap(),
|
||||
])
|
||||
.current_dir(&repo_path);
|
||||
|
||||
cmd.assert()
|
||||
.failure()
|
||||
.stderr(predicate::str::contains("Invalid conventional commit format"));
|
||||
cmd.assert().failure().stderr(predicate::str::contains(
|
||||
"Invalid conventional commit format",
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user