use std::fs;
use crate::test_utils::*;
use anyhow::Result;
#[tokio::test]
async fn test_basic_rm() -> Result<()> {
let dir = tempfile::tempdir()?;
let dst_path = dir.path().join("dst.txt");
let expect = "hello";
fs::write(&dst_path, expect)?;
assert_snapshot!(directory_snapshot(dir.path()).with_content(true), @r"
+-------------------------------------+
| Path Type Content |
+=====================================+
| [TEMP_DIR] DIR |
| [TEMP_DIR]/dst.txt FILE hello |
+-------------------------------------+
");
oli().arg("rm").arg(dst_path).assert().success();
assert_snapshot!(directory_snapshot(dir.path()).with_content(true), @r"
+-----------------------------+
| Path Type Content |
+=============================+
| [TEMP_DIR] DIR |
+-----------------------------+
");
Ok(())
}
#[tokio::test]
async fn test_rm_for_path_in_current_dir() -> Result<()> {
let dir = tempfile::tempdir()?;
let dst_path = dir.path().join("dst.txt");
let expect = "hello";
fs::write(&dst_path, expect)?;
assert_snapshot!(directory_snapshot(dir.path()).with_content(true), @r"
+-------------------------------------+
| Path Type Content |
+=====================================+
| [TEMP_DIR] DIR |
| [TEMP_DIR]/dst.txt FILE hello |
+-------------------------------------+
");
oli()
.arg("rm")
.arg("dst.txt")
.current_dir(dir.path())
.assert()
.success();
assert_snapshot!(directory_snapshot(dir.path()).with_content(true), @r"
+-----------------------------+
| Path Type Content |
+=============================+
| [TEMP_DIR] DIR |
+-----------------------------+
");
Ok(())
}