#![allow(
clippy::unwrap_used,
clippy::expect_used,
clippy::panic,
clippy::needless_raw_string_hashes,
clippy::duration_suboptimal_units,
clippy::branches_sharing_code,
clippy::used_underscore_binding,
clippy::single_char_pattern,
clippy::ignore_without_reason,
clippy::cloned_ref_to_slice_refs,
clippy::doc_overindented_list_items,
clippy::match_wildcard_for_single_variants,
clippy::ignored_unit_patterns,
clippy::needless_collect,
clippy::unnecessary_map_or,
clippy::manual_flatten,
clippy::manual_strip,
clippy::future_not_send,
clippy::unnested_or_patterns,
clippy::no_effect_underscore_binding,
clippy::literal_string_with_formatting_args
)]
use assert_cmd::Command;
use predicates::prelude::*;
use tempfile::TempDir;
fn ggen() -> Command {
Command::cargo_bin("ggen").expect("Failed to find ggen binary")
}
#[test]
#[ignore]
fn test_ai_generate_executes() {
let temp_dir = TempDir::new().unwrap();
ggen()
.arg("ai")
.arg("generate")
.arg("write a hello world function")
.current_dir(&temp_dir)
.assert()
.success();
}
#[test]
#[ignore]
fn test_ai_generate_with_language() {
let temp_dir = TempDir::new().unwrap();
ggen()
.arg("ai")
.arg("generate")
.arg("write a function")
.arg("--language")
.arg("rust")
.current_dir(&temp_dir)
.assert()
.success();
}
#[test]
#[ignore]
fn test_ai_generate_with_model() {
let temp_dir = TempDir::new().unwrap();
ggen()
.arg("ai")
.arg("generate")
.arg("test prompt")
.arg("--model")
.arg("claude-3")
.current_dir(&temp_dir)
.assert()
.success();
}
#[test]
#[ignore]
fn test_ai_chat_executes() {
let temp_dir = TempDir::new().unwrap();
ggen()
.arg("ai")
.arg("chat")
.arg("--message")
.arg("hello")
.current_dir(&temp_dir)
.assert()
.success();
}
#[test]
#[ignore]
fn test_ai_chat_interactive() {
let temp_dir = TempDir::new().unwrap();
ggen()
.arg("ai")
.arg("chat")
.arg("--interactive")
.current_dir(&temp_dir)
.assert()
.success();
}
#[test]
#[ignore]
fn test_ai_analyze_executes() {
let temp_dir = TempDir::new().unwrap();
let test_file = temp_dir.path().join("test.rs");
std::fs::write(&test_file, "fn main() { println!(\"hello\"); }").unwrap();
ggen()
.arg("ai")
.arg("analyze")
.arg("--file")
.arg(test_file.to_str().unwrap())
.current_dir(&temp_dir)
.assert()
.success();
}
#[test]
#[ignore]
fn test_ai_analyze_with_code() {
let temp_dir = TempDir::new().unwrap();
ggen()
.arg("ai")
.arg("analyze")
.arg("--code")
.arg("fn test() {}")
.current_dir(&temp_dir)
.assert()
.success();
}
#[test]
#[ignore]
fn test_ai_help_shows_verbs() {
ggen()
.arg("ai")
.arg("--help")
.assert()
.success()
.stdout(predicate::str::contains("generate"))
.stdout(predicate::str::contains("chat"))
.stdout(predicate::str::contains("analyze"));
}
#[test]
#[ignore]
fn test_ai_generate_help() {
ggen()
.arg("ai")
.arg("generate")
.arg("--help")
.assert()
.success()
.stdout(predicate::str::contains("prompt").or(predicate::str::contains("generate")));
}
#[test]
#[ignore]
fn test_ai_invalid_verb() {
ggen()
.arg("ai")
.arg("invalid-verb")
.assert()
.failure()
.stderr(predicate::str::contains("error").or(predicate::str::contains("invalid")));
}