mirror of
https://github.com/hanzoai/dev.git
synced 2026-10-25 03:32:32 +00:00
After the bin rename (codex->dev) and the hanzo default provider, upstream tests broke:
- 29 cargo_bin("codex") -> cargo_bin("dev") (integration tests spawned a
non-existent `codex` binary).
- exec integration tests (28) reached the real api.hanzo.ai because the mock
harness only overrode openai_base_url while the default provider is hanzo.
Fix: ONE DRY helper mock_server_config_overrides() (sets openai_base_url AND
pins the openai provider), consumed by cmd_with_server AND the resume test
(which had duplicated the override inline — the actual cause of its failure).
- doctor insta snapshot prefix codex__ -> dev__ (snapshot name tracks the bin
crate name).
- core feedback_tags doctest: bind the example vars so it compiles.
- main.rs plugin-marketplace help assertions codex -> dev (bin_name is dev).
Full workspace: 4552 passed. The remaining agent-graph-store failures are sqlite
pool-acquire saturation under full-workspace parallelism (30s timeout exceeded
when 100+ test binaries hit /tmp sqlite at once); they pass in isolation. CI
bounds this with nextest.
120 lines
3.0 KiB
Rust
120 lines
3.0 KiB
Rust
use std::fs;
|
|
|
|
use assert_cmd::Command;
|
|
use pretty_assertions::assert_eq;
|
|
use serde_json::json;
|
|
use tempfile::TempDir;
|
|
|
|
#[test]
|
|
fn execpolicy_check_matches_expected_json() -> Result<(), Box<dyn std::error::Error>> {
|
|
let codex_home = TempDir::new()?;
|
|
let policy_path = codex_home.path().join("rules").join("policy.rules");
|
|
fs::create_dir_all(
|
|
policy_path
|
|
.parent()
|
|
.expect("policy path should have a parent"),
|
|
)?;
|
|
fs::write(
|
|
&policy_path,
|
|
r#"
|
|
prefix_rule(
|
|
pattern = ["git", "push"],
|
|
decision = "forbidden",
|
|
)
|
|
"#,
|
|
)?;
|
|
|
|
let output = Command::new(codex_utils_cargo_bin::cargo_bin("dev")?)
|
|
.env("CODEX_HOME", codex_home.path())
|
|
.args([
|
|
"execpolicy",
|
|
"check",
|
|
"--rules",
|
|
policy_path
|
|
.to_str()
|
|
.expect("policy path should be valid UTF-8"),
|
|
"git",
|
|
"push",
|
|
"origin",
|
|
"main",
|
|
])
|
|
.output()?;
|
|
|
|
assert!(output.status.success());
|
|
let result: serde_json::Value = serde_json::from_slice(&output.stdout)?;
|
|
assert_eq!(
|
|
result,
|
|
json!({
|
|
"decision": "forbidden",
|
|
"matchedRules": [
|
|
{
|
|
"prefixRuleMatch": {
|
|
"matchedPrefix": ["git", "push"],
|
|
"decision": "forbidden"
|
|
}
|
|
}
|
|
]
|
|
})
|
|
);
|
|
|
|
Ok(())
|
|
}
|
|
|
|
#[test]
|
|
fn execpolicy_check_includes_justification_when_present() -> Result<(), Box<dyn std::error::Error>>
|
|
{
|
|
let codex_home = TempDir::new()?;
|
|
let policy_path = codex_home.path().join("rules").join("policy.rules");
|
|
fs::create_dir_all(
|
|
policy_path
|
|
.parent()
|
|
.expect("policy path should have a parent"),
|
|
)?;
|
|
fs::write(
|
|
&policy_path,
|
|
r#"
|
|
prefix_rule(
|
|
pattern = ["git", "push"],
|
|
decision = "forbidden",
|
|
justification = "pushing is blocked in this repo",
|
|
)
|
|
"#,
|
|
)?;
|
|
|
|
let output = Command::new(codex_utils_cargo_bin::cargo_bin("dev")?)
|
|
.env("CODEX_HOME", codex_home.path())
|
|
.args([
|
|
"execpolicy",
|
|
"check",
|
|
"--rules",
|
|
policy_path
|
|
.to_str()
|
|
.expect("policy path should be valid UTF-8"),
|
|
"git",
|
|
"push",
|
|
"origin",
|
|
"main",
|
|
])
|
|
.output()?;
|
|
|
|
assert!(output.status.success());
|
|
let result: serde_json::Value = serde_json::from_slice(&output.stdout)?;
|
|
assert_eq!(
|
|
result,
|
|
json!({
|
|
"decision": "forbidden",
|
|
"matchedRules": [
|
|
{
|
|
"prefixRuleMatch": {
|
|
"matchedPrefix": ["git", "push"],
|
|
"decision": "forbidden",
|
|
"justification": "pushing is blocked in this repo"
|
|
}
|
|
}
|
|
]
|
|
})
|
|
);
|
|
|
|
Ok(())
|
|
}
|