-
Notifications
You must be signed in to change notification settings - Fork 160
Expand file tree
/
Copy pathai_review_integration.rs
More file actions
48 lines (40 loc) · 1.22 KB
/
Copy pathai_review_integration.rs
File metadata and controls
48 lines (40 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
use assert_cmd::Command;
use predicates::prelude::*;
use std::fs;
#[test]
#[ignore] // Requires a running Ollama instance with a model.
fn test_ai_review_markdown_output() -> Result<(), Box<dyn std::error::Error>> {
let temp_dir = tempfile::tempdir()?;
let file_path = temp_dir.path().join("test_contract.rs");
let code = r#"
#[contract]
pub struct HelloContract;
#[contractimpl]
impl HelloContract {
pub fn hello(env: Env, to: Symbol) -> Symbol {
symbol_short!("Hello")
}
}
"#;
fs::write(&file_path, code)?;
let mut cmd = Command::cargo_bin("starforge")?;
cmd.arg("review")
.arg(file_path.to_str().unwrap())
.arg("--output")
.arg("markdown");
cmd.assert()
.success()
.stdout(predicate::str::contains("# AI Code Review Report"))
.stdout(predicate::str::contains("Overall Score:"))
.stdout(predicate::str::contains("Summary:"));
Ok(())
}
#[test]
fn test_ai_review_file_not_found() -> Result<(), Box<dyn std::error::Error>> {
let mut cmd = Command::cargo_bin("starforge")?;
cmd.arg("review").arg("non_existent_file.rs");
cmd.assert()
.failure()
.stderr(predicate::str::contains("Failed to read file"));
Ok(())
}