summaryrefslogtreecommitdiffstats
path: root/tests/config.rs
diff options
context:
space:
mode:
authoraur-build <aur-build@localhost>2026-11-22 10:36:24 +0000
committeraur-build <aur-build@localhost>2026-11-22 10:36:24 +0000
commit3dc71b2f5160ef9bd46143eed0edb5d2557b58e6 (patch)
tree7cc7169181b4bdd73fd8817f8c1d7cce6e6998a8 /tests/config.rs
parent9dc9087d89891c6e5ef7e5dc084dd13c8611843e (diff)
downloadaur-build-3dc71b2f5160ef9bd46143eed0edb5d2557b58e6.tar.gz
aur-build-3dc71b2f5160ef9bd46143eed0edb5d2557b58e6.zip
rustfmt,lints: pin the formatting, adopt the idiom lints, pay them off
rustfmt.toml fixes the shape the tree is written in (120 columns, small items kept on one line) and one canonical pass makes it the truth. [lints.clippy] names the idiom lints worth enforcing and leaves out the two that would add doc-comment boilerplate rather than remove it. The tree pays them off here: write!/writeln! instead of push_str(&format!()), let-else instead of match-on-Option, borrows where a thread entry point only reads what it owns, no `&self` on a Copy state and no `self` nobody reads. ops::to_prometheus gains one gauge helper: a metric's HELP, TYPE and value are now emitted by the same call instead of three.
Diffstat (limited to 'tests/config.rs')
-rw-r--r--tests/config.rs28
1 files changed, 5 insertions, 23 deletions
diff --git a/tests/config.rs b/tests/config.rs
index 6c58122..86222a8 100644
--- a/tests/config.rs
+++ b/tests/config.rs
@@ -16,10 +16,7 @@ fn a_relative_root_is_absolutized_once_and_never_doubled() {
let rel = PathBuf::from("target").join("config-root-test").join("runtime");
let _ = std::fs::remove_dir_all(&rel);
- let cfg = Config {
- root: rel.clone(),
- ..Config::default()
- };
+ let cfg = Config { root: rel.clone(), ..Config::default() };
cfg.save().unwrap();
let reloaded = Config::load(&rel).unwrap();
@@ -43,11 +40,7 @@ fn a_relative_root_is_absolutized_once_and_never_doubled() {
#[test]
fn a_stale_relative_root_in_the_file_is_ignored() {
let tmp = tempfile::tempdir().unwrap();
- std::fs::write(
- tmp.path().join("config.json"),
- "{\n \"root\": \"runtime\"\n}\n",
- )
- .unwrap();
+ std::fs::write(tmp.path().join("config.json"), "{\n \"root\": \"runtime\"\n}\n").unwrap();
let cfg = Config::load(tmp.path()).unwrap();
assert_eq!(cfg.root, std::path::absolute(tmp.path()).unwrap());
assert!(!cfg.root.join("runtime").exists());
@@ -70,10 +63,7 @@ fn the_cli_refuses_a_root_that_was_never_initialized() {
.args(["--root", &tmp.path().display().to_string(), "packages"])
.output()
.unwrap();
- assert!(
- !out.status.success(),
- "a root with no config must fail, not answer from an empty server"
- );
+ assert!(!out.status.success(), "a root with no config must fail, not answer from an empty server");
assert!(
out.stdout.is_empty(),
"nothing may be printed as though the server existed: {}",
@@ -91,11 +81,7 @@ fn init_still_runs_where_there_is_no_config_yet() {
.args(["--root", &root.display().to_string(), "init", "--repo", "aur"])
.output()
.unwrap();
- assert!(
- out.status.success(),
- "{}",
- String::from_utf8_lossy(&out.stderr)
- );
+ assert!(out.status.success(), "{}", String::from_utf8_lossy(&out.stderr));
assert!(root.join("config.json").exists());
assert!(root.join("aur-build.db").exists());
@@ -108,11 +94,7 @@ fn init_still_runs_where_there_is_no_config_yet() {
fn an_absolute_root_is_used_verbatim() {
let tmp = tempfile::tempdir().unwrap();
let dir: &Path = tmp.path();
- std::fs::write(
- dir.join("config.json"),
- format!("{{\n \"root\": \"{}\"\n}}\n", dir.display()),
- )
- .unwrap();
+ std::fs::write(dir.join("config.json"), format!("{{\n \"root\": \"{}\"\n}}\n", dir.display())).unwrap();
assert_eq!(Config::load(dir).unwrap().root, dir);
}