mirror of
https://github.com/fabro-sh/fabro.git
synced 2026-08-28 05:27:41 +00:00
Adopt write_temp/write_home helpers across cmd/ tests
Replace manual std::fs::create_dir_all + std::fs::write boilerplate with context.write_temp() and context.write_home() in repo, workflow, exec, and run tests. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
fa43f8f780
commit
cb072aed75
4 changed files with 17 additions and 23 deletions
|
|
@ -172,7 +172,7 @@ fn exec_json_output_format() {
|
|||
fn exec_read_and_edit() {
|
||||
dotenvy::dotenv().ok();
|
||||
let context = test_context!();
|
||||
std::fs::write(context.temp_dir.join("data.txt"), "old content").expect("write data.txt");
|
||||
context.write_temp("data.txt", "old content");
|
||||
context
|
||||
.exec_cmd()
|
||||
.args([
|
||||
|
|
|
|||
|
|
@ -9,12 +9,11 @@ fn init_git_repo(path: &std::path::Path) {
|
|||
.expect("git init should succeed");
|
||||
}
|
||||
|
||||
fn init_fabro_project(path: &std::path::Path) {
|
||||
std::fs::write(path.join("fabro.toml"), "version = 1\n").unwrap();
|
||||
let workflow_dir = path.join("fabro/workflows/hello");
|
||||
std::fs::create_dir_all(&workflow_dir).unwrap();
|
||||
std::fs::write(workflow_dir.join("workflow.fabro"), "digraph {}").unwrap();
|
||||
std::fs::write(workflow_dir.join("workflow.toml"), "version = 1\n").unwrap();
|
||||
fn init_fabro_project(context: &fabro_test::TestContext) {
|
||||
context
|
||||
.write_temp("fabro.toml", "version = 1\n")
|
||||
.write_temp("fabro/workflows/hello/workflow.fabro", "digraph {}")
|
||||
.write_temp("fabro/workflows/hello/workflow.toml", "version = 1\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
@ -50,7 +49,7 @@ fn help() {
|
|||
fn test_repo_deinit_removes_fabro_toml_and_dir() {
|
||||
let context = test_context!();
|
||||
init_git_repo(&context.temp_dir);
|
||||
init_fabro_project(&context.temp_dir);
|
||||
init_fabro_project(&context);
|
||||
|
||||
assert!(context.temp_dir.join("fabro.toml").exists());
|
||||
assert!(context.temp_dir.join("fabro").exists());
|
||||
|
|
|
|||
|
|
@ -1157,9 +1157,8 @@ digraph G {
|
|||
#[test]
|
||||
fn bug4_detached_resume_rejects_completed_run_without_mutating_it() {
|
||||
let context = test_context!();
|
||||
let workflow_path = context.temp_dir.join("workflow.fabro");
|
||||
std::fs::write(
|
||||
&workflow_path,
|
||||
context.write_temp(
|
||||
"workflow.fabro",
|
||||
"\
|
||||
digraph Test {
|
||||
start [shape=Mdiamond, label=\"Start\"]
|
||||
|
|
@ -1167,8 +1166,7 @@ digraph Test {
|
|||
start -> exit
|
||||
}
|
||||
",
|
||||
)
|
||||
.unwrap();
|
||||
);
|
||||
|
||||
let run = context
|
||||
.command()
|
||||
|
|
@ -1179,7 +1177,7 @@ digraph Test {
|
|||
"--auto-approve",
|
||||
"--no-retro",
|
||||
"--detach",
|
||||
workflow_path.to_str().unwrap(),
|
||||
context.temp_dir.join("workflow.fabro").to_str().unwrap(),
|
||||
])
|
||||
.assert()
|
||||
.success();
|
||||
|
|
|
|||
|
|
@ -5,15 +5,12 @@ use predicates;
|
|||
fn list() {
|
||||
let context = test_context!();
|
||||
|
||||
// Minimal project structure: fabro.toml + a workflow
|
||||
std::fs::write(context.temp_dir.join("fabro.toml"), "version = 1\n").unwrap();
|
||||
let wf_dir = context.temp_dir.join("workflows/my_test_wf");
|
||||
std::fs::create_dir_all(&wf_dir).unwrap();
|
||||
std::fs::write(
|
||||
wf_dir.join("workflow.toml"),
|
||||
"version = 1\ngoal = \"A test workflow\"\n",
|
||||
)
|
||||
.unwrap();
|
||||
context
|
||||
.write_temp("fabro.toml", "version = 1\n")
|
||||
.write_temp(
|
||||
"workflows/my_test_wf/workflow.toml",
|
||||
"version = 1\ngoal = \"A test workflow\"\n",
|
||||
);
|
||||
|
||||
context
|
||||
.command()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue