Format codebase with rustfmt

This commit is contained in:
thePR0M3TH3AN
2025-05-21 11:24:49 -04:00
parent 9360efee2a
commit 567f1cd1a5
33 changed files with 780 additions and 481 deletions

View File

@@ -5,7 +5,7 @@
mod util;
use util::marlin;
use predicates::{prelude::*, str}; // brings `PredicateBooleanExt::and`
use predicates::{prelude::*, str}; // brings `PredicateBooleanExt::and`
use std::fs;
use tempfile::tempdir;
@@ -13,15 +13,20 @@ use tempfile::tempdir;
#[test]
fn tag_should_add_hierarchical_tag_and_search_finds_it() {
let tmp = tempdir().unwrap();
let tmp = tempdir().unwrap();
let file = tmp.path().join("foo.md");
fs::write(&file, "# test\n").unwrap();
marlin(&tmp).current_dir(tmp.path()).arg("init").assert().success();
marlin(&tmp)
.current_dir(tmp.path())
.arg("init")
.assert()
.success();
marlin(&tmp)
.args(["tag", file.to_str().unwrap(), "project/md"])
.assert().success();
.assert()
.success();
marlin(&tmp)
.args(["search", "tag:project/md"])
@@ -34,15 +39,20 @@ fn tag_should_add_hierarchical_tag_and_search_finds_it() {
#[test]
fn attr_set_then_ls_roundtrip() {
let tmp = tempdir().unwrap();
let tmp = tempdir().unwrap();
let file = tmp.path().join("report.pdf");
fs::write(&file, "%PDF-1.4\n").unwrap();
marlin(&tmp).current_dir(tmp.path()).arg("init").assert().success();
marlin(&tmp)
.current_dir(tmp.path())
.arg("init")
.assert()
.success();
marlin(&tmp)
.args(["attr", "set", file.to_str().unwrap(), "reviewed", "yes"])
.assert().success();
.assert()
.success();
marlin(&tmp)
.args(["attr", "ls", file.to_str().unwrap()])
@@ -62,11 +72,21 @@ fn coll_create_add_and_list() {
fs::write(&a, "").unwrap();
fs::write(&b, "").unwrap();
marlin(&tmp).current_dir(tmp.path()).arg("init").assert().success();
marlin(&tmp)
.current_dir(tmp.path())
.arg("init")
.assert()
.success();
marlin(&tmp).args(["coll", "create", "Set"]).assert().success();
marlin(&tmp)
.args(["coll", "create", "Set"])
.assert()
.success();
for f in [&a, &b] {
marlin(&tmp).args(["coll", "add", "Set", f.to_str().unwrap()]).assert().success();
marlin(&tmp)
.args(["coll", "add", "Set", f.to_str().unwrap()])
.assert()
.success();
}
marlin(&tmp)
@@ -80,15 +100,22 @@ fn coll_create_add_and_list() {
#[test]
fn view_save_list_and_exec() {
let tmp = tempdir().unwrap();
let tmp = tempdir().unwrap();
let todo = tmp.path().join("TODO.txt");
fs::write(&todo, "remember the milk\n").unwrap();
marlin(&tmp).current_dir(tmp.path()).arg("init").assert().success();
marlin(&tmp)
.current_dir(tmp.path())
.arg("init")
.assert()
.success();
// save & list
marlin(&tmp).args(["view", "save", "tasks", "milk"]).assert().success();
marlin(&tmp)
.args(["view", "save", "tasks", "milk"])
.assert()
.success();
marlin(&tmp)
.args(["view", "list"])
.assert()
@@ -118,24 +145,30 @@ fn link_add_rm_and_list() {
let mc = || marlin(&tmp);
mc().current_dir(tmp.path()).arg("init").assert().success();
mc().args(["scan", tmp.path().to_str().unwrap()]).assert().success();
mc().args(["scan", tmp.path().to_str().unwrap()])
.assert()
.success();
// add
mc().args(["link", "add", foo.to_str().unwrap(), bar.to_str().unwrap()])
.assert().success();
.assert()
.success();
// list (outgoing default)
mc().args(["link", "list", foo.to_str().unwrap()])
.assert().success()
.assert()
.success()
.stdout(str::contains("foo.txt").and(str::contains("bar.txt")));
// remove
mc().args(["link", "rm", foo.to_str().unwrap(), bar.to_str().unwrap()])
.assert().success();
.assert()
.success();
// list now empty
mc().args(["link", "list", foo.to_str().unwrap()])
.assert().success()
.assert()
.success()
.stdout(str::is_empty());
}
@@ -154,19 +187,24 @@ fn scan_with_multiple_paths_indexes_all() {
fs::write(&f1, "").unwrap();
fs::write(&f2, "").unwrap();
marlin(&tmp).current_dir(tmp.path()).arg("init").assert().success();
marlin(&tmp)
.current_dir(tmp.path())
.arg("init")
.assert()
.success();
// multi-path scan
marlin(&tmp)
.args(["scan", dir_a.to_str().unwrap(), dir_b.to_str().unwrap()])
.assert().success();
.assert()
.success();
// both files findable
for term in ["one.txt", "two.txt"] {
marlin(&tmp).args(["search", term])
marlin(&tmp)
.args(["search", term])
.assert()
.success()
.stdout(str::contains(term));
}
}