#![cfg(feature = "integration")]
use anyhow::Result;
use git_iris::cli::Commands;
use git_iris::common::CommonParams;
use git_iris::git::GitRepo;
use std::env;
#[tokio::test]
async fn test_cli_with_remote_repository() -> Result<()> {
if env::var("CI").is_ok() || env::var("SKIP_REMOTE_TESTS").is_ok() {
return Ok(());
}
let repo_url = "https://github.com/rust-lang/rust.git";
let git_repo = GitRepo::new_from_url(Some(repo_url.to_string()))?;
assert!(
git_repo.is_remote(),
"Repository should be marked as remote"
);
let common = CommonParams {
provider: Some("mock".to_string()), model: None,
instructions: None,
preset: None,
gitmoji_flag: false,
no_gitmoji: false,
gitmoji: Some(false),
repository_url: Some(repo_url.to_string()),
};
let release_notes_command = Commands::ReleaseNotes {
common: common.clone(),
from: "v1.0.0".to_string(), to: Some("HEAD".to_string()),
raw: false,
update: false,
file: None,
version_name: None,
};
let result = git_iris::cli::handle_command(release_notes_command, None).await;
assert!(
result.is_err(),
"Command should fail because we're using a mock provider"
);
let changelog_command = Commands::Changelog {
common: common.clone(),
from: "v1.0.0".to_string(),
to: Some("HEAD".to_string()),
raw: false,
file: None,
update: false,
version_name: None,
};
let result = git_iris::cli::handle_command(changelog_command, None).await;
assert!(
result.is_err(),
"Command should fail because we're using a mock provider"
);
let review_command = Commands::Review {
common: common.clone(),
print: true,
raw: false,
commit: None,
include_unstaged: false,
from: None,
to: None,
};
let result = git_iris::cli::handle_command(review_command, None).await;
assert!(
result.is_err(),
"Command should fail because we're using a mock provider"
);
let gen_command = Commands::Gen {
common,
auto_commit: false,
print: true,
no_verify: true,
amend: false,
};
let result = git_iris::cli::handle_command(gen_command, None).await;
assert!(
result.is_err(),
"Command should fail because we're using a mock provider"
);
Ok(())
}