clean up scenario tests

This commit is contained in:
Dylan Hurd
2026-02-18 08:59:14 -08:00
parent 5810c1b13e
commit 14cd993950
22 changed files with 66 additions and 35 deletions

View File

@@ -0,0 +1,7 @@
*** Begin Patch
*** Update File: sample.txt
@@
-one
+uno
two
*** End Patch

View File

@@ -0,0 +1,5 @@
*** Begin Patch
*** Add File: created.txt
+hello
+world
*** End Patch

View File

@@ -0,0 +1,3 @@
first
second
third

View File

@@ -0,0 +1,7 @@
*** Begin Patch
*** Update File: lines.txt
@@
first
-second
third
*** End Patch

View File

@@ -0,0 +1,8 @@
*** Begin Patch
*** Update File: old/name.txt
*** Move to: renamed/dir/name.txt
@@
-old
+new
line
*** End Patch

View File

@@ -0,0 +1,4 @@
one
dos
three
cuatro

View File

@@ -0,0 +1,4 @@
one
two
three
four

View File

@@ -0,0 +1,9 @@
*** Begin Patch
*** Update File: multi.txt
@@
-two
+dos
@@
-four
+cuatro
*** End Patch

View File

@@ -124,38 +124,3 @@ fn copy_dir_recursive(src: &Path, dst: &Path) -> anyhow::Result<()> {
}
Ok(())
}
#[test]
fn test_apply_patch_preserves_crlf_for_update_hunks() -> anyhow::Result<()> {
let tmp = tempdir()?;
let file_path = tmp.path().join("sample.txt");
fs::write(&file_path, b"one\r\ntwo\r\n")?;
let patch = "*** Begin Patch\r\n*** Update File: sample.txt\r\n@@\r\n-one\r\n+uno\r\n two\r\n*** End Patch\r\n";
Command::new(codex_utils_cargo_bin::cargo_bin("apply_patch")?)
.arg(patch)
.current_dir(tmp.path())
.output()?;
assert_eq!(fs::read(&file_path)?, b"uno\r\ntwo\r\n");
Ok(())
}
#[test]
fn test_apply_patch_preserves_crlf_for_add_file_hunks() -> anyhow::Result<()> {
let tmp = tempdir()?;
let patch =
"*** Begin Patch\r\n*** Add File: created.txt\r\n+hello\r\n+world\r\n*** End Patch\r\n";
Command::new(codex_utils_cargo_bin::cargo_bin("apply_patch")?)
.arg(patch)
.current_dir(tmp.path())
.output()?;
assert_eq!(
fs::read(tmp.path().join("created.txt"))?,
b"hello\r\nworld\r\n"
);
Ok(())
}