mirror of
https://github.com/PR0M3TH3AN/Marlin.git
synced 2025-09-10 08:08:43 +00:00
Format codebase with rustfmt
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
Reference in New Issue
Block a user