Files
Marcos Paulo 5e8020aa38
ci / ci (macos-latest) (push) Has been cancelled
ci / ci (ubuntu-latest) (push) Has been cancelled
ci / ci (windows-latest) (push) Has been cancelled
feat: Obsidian basics, editor previews, graph rework, query blocks, stacked tabs, pop-out windows
Editor previews (colour swatches, arrows, embeds), the 18 obsidian-basics tasks (find and replace
with regex, back/forward, auto-pair, footnotes, folding, search operators, split view, PDF/audio/
video embeds, spelling, drag and drop, pinned tabs, settings) and round 2: ```query blocks, stacked
tabs, pop-out windows, tasks ticked inside embeds, text around an embed, embeds that follow edits,
block menu shortcut. New crates: notescraft-regex (linear-time engine) and notescraft-syntax.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-19 11:21:19 -03:00

38 lines
1.4 KiB
Rust

//! `session.files.deleted_files`: trash by default, erase for good when asked.
mod common;
use common::{temp_config, temp_vault};
use notescraft_engine::{Registry, Session, register_core};
use serde_json::json;
fn delete_with(setting: Option<&str>, name: &str) -> (std::path::PathBuf, bool) {
let vault = temp_vault(name);
let config = temp_config(name);
std::fs::write(vault.path().join("gone.md"), "# gone\n").expect("write");
let mut registry = Registry::new();
register_core(&mut registry).expect("register");
let mut session = Session::open(vault.path()).expect("open");
session.use_settings_dir(config.path());
if let Some(value) = setting {
registry.run("settings.set", &mut session, &json!({ "key": "session.files.deleted_files", "value": value })).expect("set");
}
registry.run("note.delete", &mut session, &json!({ "path": "gone.md" })).expect("delete");
let trash = vault.path().join(".notescraft/trash");
(vault.path().join("gone.md"), trash.exists())
}
#[test]
fn the_default_keeps_a_trash_copy() {
let (file, trash) = delete_with(None, "deleted-default");
assert!(!file.exists());
assert!(trash, "moved to the vault trash");
}
#[test]
fn permanent_erases_the_file_without_a_copy() {
let (file, trash) = delete_with(Some("permanent"), "deleted-permanent");
assert!(!file.exists());
assert!(!trash, "no trash folder was made");
}