use std::path::PathBuf;
use vcs_gitea::{Gitea, GiteaApi};
async fn tea_present() -> bool {
Gitea::new().version().await.is_ok()
}
fn test_repo() -> PathBuf {
std::env::var_os("VCS_GITEA_TEST_REPO")
.map(PathBuf::from)
.unwrap_or_else(|| std::env::current_dir().expect("cwd"))
}
fn assert_not_parse_error<T>(label: &str, result: processkit::Result<T>) {
match result {
Ok(_) => {} Err(processkit::Error::Parse { message, .. }) => {
panic!("{label}: tea output did not match the parser (contract drift): {message}");
}
Err(other) => eprintln!("skipping {label}: {other}"),
}
}
#[tokio::test]
#[ignore = "requires the tea binary"]
async fn version_runs() {
if !tea_present().await {
eprintln!("skipping: tea not installed");
return;
}
let v = Gitea::new().version().await.expect("tea version");
assert!(!v.trim().is_empty(), "expected a version string");
}
#[tokio::test]
#[ignore = "requires the tea binary"]
async fn auth_status_does_not_error() {
if !tea_present().await {
eprintln!("skipping: tea not installed");
return;
}
let _authed = Gitea::new()
.auth_status()
.await
.expect("auth_status should not error");
}
#[tokio::test]
#[ignore = "requires the tea binary + a real Gitea repo/login"]
async fn list_outputs_match_the_parsers() {
if !tea_present().await {
eprintln!("skipping: tea not installed");
return;
}
let tea = Gitea::new();
let dir = test_repo();
assert_not_parse_error("pr_list", tea.pr_list(&dir).await);
assert_not_parse_error("issue_list", tea.issue_list(&dir).await);
assert_not_parse_error("release_list", tea.release_list(&dir).await);
assert_not_parse_error("issue_view", tea.issue_view(&dir, 1).await);
}