WIP: Batch 2 — backfill tests for fs, shell, and http/workflow
- io/fs.rs: 20 tests (path resolution, project open/close/get, known projects, model prefs, file read/write, list dir, validate path, scaffold) - io/shell.rs: 4 new tests (allowlist, command execution, stdout capture, exit codes) - http/workflow.rs: 8 tests (parse_test_status, to_test_case, to_review_story) Coverage: 28.6% → 48.1% Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -317,3 +317,108 @@ fn parse_test_status(value: &str) -> Result<TestStatus, String> {
|
||||
)),
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::workflow::{StoryTestResults, TestCaseResult, TestStatus};
|
||||
|
||||
#[test]
|
||||
fn parse_test_status_pass() {
|
||||
assert_eq!(parse_test_status("pass").unwrap(), TestStatus::Pass);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_test_status_fail() {
|
||||
assert_eq!(parse_test_status("fail").unwrap(), TestStatus::Fail);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_test_status_invalid() {
|
||||
let result = parse_test_status("unknown");
|
||||
assert!(result.is_err());
|
||||
assert!(result.unwrap_err().contains("Invalid test status"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn to_test_case_converts_pass() {
|
||||
let payload = TestCasePayload {
|
||||
name: "my_test".to_string(),
|
||||
status: "pass".to_string(),
|
||||
details: Some("all good".to_string()),
|
||||
};
|
||||
let result = to_test_case(payload).unwrap();
|
||||
assert_eq!(result.name, "my_test");
|
||||
assert_eq!(result.status, TestStatus::Pass);
|
||||
assert_eq!(result.details, Some("all good".to_string()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn to_test_case_rejects_invalid_status() {
|
||||
let payload = TestCasePayload {
|
||||
name: "bad".to_string(),
|
||||
status: "maybe".to_string(),
|
||||
details: None,
|
||||
};
|
||||
assert!(to_test_case(payload).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn to_review_story_all_passing() {
|
||||
let results = StoryTestResults {
|
||||
unit: vec![TestCaseResult {
|
||||
name: "u1".to_string(),
|
||||
status: TestStatus::Pass,
|
||||
details: None,
|
||||
}],
|
||||
integration: vec![TestCaseResult {
|
||||
name: "i1".to_string(),
|
||||
status: TestStatus::Pass,
|
||||
details: None,
|
||||
}],
|
||||
};
|
||||
|
||||
let review = to_review_story("story-29", &results);
|
||||
assert!(review.can_accept);
|
||||
assert!(review.reasons.is_empty());
|
||||
assert!(review.missing_categories.is_empty());
|
||||
assert_eq!(review.summary.total, 2);
|
||||
assert_eq!(review.summary.passed, 2);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn to_review_story_missing_integration() {
|
||||
let results = StoryTestResults {
|
||||
unit: vec![TestCaseResult {
|
||||
name: "u1".to_string(),
|
||||
status: TestStatus::Pass,
|
||||
details: None,
|
||||
}],
|
||||
integration: vec![],
|
||||
};
|
||||
|
||||
let review = to_review_story("story-29", &results);
|
||||
assert!(!review.can_accept);
|
||||
assert!(review.missing_categories.contains(&"integration".to_string()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn to_review_story_with_failures() {
|
||||
let results = StoryTestResults {
|
||||
unit: vec![TestCaseResult {
|
||||
name: "u1".to_string(),
|
||||
status: TestStatus::Fail,
|
||||
details: None,
|
||||
}],
|
||||
integration: vec![TestCaseResult {
|
||||
name: "i1".to_string(),
|
||||
status: TestStatus::Pass,
|
||||
details: None,
|
||||
}],
|
||||
};
|
||||
|
||||
let review = to_review_story("story-29", &results);
|
||||
assert!(!review.can_accept);
|
||||
assert_eq!(review.summary.failed, 1);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user