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

@@ -1,6 +1,9 @@
mod cli {
#[derive(Clone, Copy, Debug)]
pub enum Format { Text, Json }
pub enum Format {
Text,
Json,
}
}
#[path = "../src/cli/coll.rs"]
@@ -11,20 +14,41 @@ use libmarlin::db;
#[test]
fn coll_run_creates_and_adds() {
let mut conn = db::open(":memory:").unwrap();
conn.execute("INSERT INTO files(path,size,mtime) VALUES ('a.txt',0,0)", []).unwrap();
conn.execute("INSERT INTO files(path,size,mtime) VALUES ('b.txt',0,0)", []).unwrap();
conn.execute(
"INSERT INTO files(path,size,mtime) VALUES ('a.txt',0,0)",
[],
)
.unwrap();
conn.execute(
"INSERT INTO files(path,size,mtime) VALUES ('b.txt',0,0)",
[],
)
.unwrap();
let create = coll::CollCmd::Create(coll::CreateArgs{ name: "Set".into() });
let create = coll::CollCmd::Create(coll::CreateArgs { name: "Set".into() });
coll::run(&create, &mut conn, cli::Format::Text).unwrap();
let coll_id: i64 = conn.query_row("SELECT id FROM collections WHERE name='Set'", [], |r| r.get(0)).unwrap();
let coll_id: i64 = conn
.query_row("SELECT id FROM collections WHERE name='Set'", [], |r| {
r.get(0)
})
.unwrap();
let add = coll::CollCmd::Add(coll::AddArgs{ name: "Set".into(), file_pattern: "*.txt".into() });
let add = coll::CollCmd::Add(coll::AddArgs {
name: "Set".into(),
file_pattern: "*.txt".into(),
});
coll::run(&add, &mut conn, cli::Format::Text).unwrap();
let cnt: i64 = conn.query_row("SELECT COUNT(*) FROM collection_files WHERE collection_id=?1", [coll_id], |r| r.get(0)).unwrap();
let cnt: i64 = conn
.query_row(
"SELECT COUNT(*) FROM collection_files WHERE collection_id=?1",
[coll_id],
|r| r.get(0),
)
.unwrap();
assert_eq!(cnt, 2);
let list = coll::CollCmd::List(coll::ListArgs{ name: "Set".into() });
let list = coll::CollCmd::List(coll::ListArgs { name: "Set".into() });
coll::run(&list, &mut conn, cli::Format::Text).unwrap();
}