diff options
Diffstat (limited to 'tests/ops.rs')
| -rw-r--r-- | tests/ops.rs | 66 |
1 files changed, 17 insertions, 49 deletions
diff --git a/tests/ops.rs b/tests/ops.rs index 821b733..4570c86 100644 --- a/tests/ops.rs +++ b/tests/ops.rs @@ -76,16 +76,10 @@ fn retention_keeps_the_newest_n_versions_and_never_deletes_a_row() { assert_eq!(env.query_i64("SELECT count(*) FROM release", &[]), Some(5)); assert_eq!(env.query_i64("SELECT count(*) FROM artifact", &[]), Some(5)); - assert_eq!( - env.query_i64("SELECT count(*) FROM artifact WHERE purged_at IS NOT NULL", &[]), - Some(3) - ); - assert_eq!( - env.query_i64("SELECT count(*) FROM release WHERE purged_at IS NOT NULL", &[]), - Some(3) - ); + assert_eq!(env.query_i64("SELECT count(*) FROM artifact WHERE purged_at IS NOT NULL", &[]), Some(3)); + assert_eq!(env.query_i64("SELECT count(*) FROM release WHERE purged_at IS NOT NULL", &[]), Some(3)); assert_eq!(env.query_i64("SELECT count(*) FROM gc_run", &[]), Some(1)); - assert!(env.query_i64("SELECT count(*) FROM audit WHERE action='retention'", &[]) == Some(1)); + assert_eq!(env.query_i64("SELECT count(*) FROM audit WHERE action='retention'", &[]), Some(1)); } #[test] @@ -95,11 +89,9 @@ fn retention_keeps_a_package_with_its_log_and_sources_as_one_unit() { let oldest = env .db .read(|c| { - Ok(c.query_row( - "SELECT id FROM release WHERE state='published' ORDER BY id LIMIT 1", - [], - |r| r.get::<_, i64>(0), - )?) + Ok(c.query_row("SELECT id FROM release WHERE state='published' ORDER BY id LIMIT 1", [], |r| { + r.get::<_, i64>(0) + })?) }) .unwrap(); let files = ops::release_files(&env.cfg, &env.db, oldest).unwrap(); @@ -124,19 +116,13 @@ fn retention_keeps_a_package_with_its_log_and_sources_as_one_unit() { let (pkg, sig, log) = &held[0]; for (what, p) in [("package", pkg), ("signature", sig), ("build log", log)] { let p = p.as_ref().unwrap_or_else(|| panic!("the release should hold a {what}")); - assert!( - files.iter().any(|f| f == Path::new(p)), - "release_files must include the {what} ({p}): {files:?}" - ); + assert!(files.iter().any(|f| f == Path::new(p)), "release_files must include the {what} ({p}): {files:?}"); assert!(Path::new(p).exists(), "the {what} should exist before eviction"); } ops::retention(&env.cfg, &env.db, Some(1)).unwrap(); let still_there: Vec<&PathBuf> = files.iter().filter(|f| f.exists()).collect(); - assert!( - still_there.is_empty(), - "evicting a release must take its log and signature with it: {still_there:?}" - ); + assert!(still_there.is_empty(), "evicting a release must take its log and signature with it: {still_there:?}"); } #[test] @@ -156,25 +142,17 @@ fn retention_never_evicts_the_version_the_index_is_serving() { let served_release = env .db .read(|c| { - Ok(c.query_row( - "SELECT p.release_id FROM package p WHERE p.state='in_index' LIMIT 1", - [], - |r| r.get::<_, i64>(0), - )?) + Ok(c.query_row("SELECT p.release_id FROM package p WHERE p.state='in_index' LIMIT 1", [], |r| { + r.get::<_, i64>(0) + })?) }) .unwrap(); env.exec("UPDATE package SET state='removed' WHERE state='in_index'", &[]); - env.exec( - "UPDATE package SET state='in_index' WHERE release_id=?1", - &[P::I(served_release)], - ); + env.exec("UPDATE package SET state='in_index' WHERE release_id=?1", &[P::I(served_release)]); let report = ops::retention(&env.cfg, &env.db, Some(1)).unwrap(); assert!(report.releases_evicted >= 1, "something should have been evicted: {report:?}"); - assert!( - Path::new(&served).exists(), - "retention deleted the artifact the index is serving: {served}" - ); + assert!(Path::new(&served).exists(), "retention deleted the artifact the index is serving: {served}"); } #[test] @@ -231,10 +209,7 @@ fn metrics_reports_the_operating_numbers_in_prometheus_format() { } for line in text.lines().filter(|l| !l.starts_with('#')) { let tail = line.rsplit(' ').next().unwrap_or(""); - assert!( - tail.parse::<f64>().is_ok(), - "not a prometheus sample: {line:?}" - ); + assert!(tail.parse::<f64>().is_ok(), "not a prometheus sample: {line:?}"); } for line in text.lines().filter(|l| l.starts_with("# TYPE")) { let name = line.split_whitespace().nth(2).unwrap(); @@ -277,11 +252,7 @@ fn the_http_metrics_endpoint_serves_scrapeable_text() { assert!(page.body.contains("aurbuild_sqlite_wal_size_bytes")); let (headers, body) = web.raw_get("/metrics"); assert!(body.contains("aurbuild_up 1"), "metrics should be reachable unauthenticated"); - let ct = headers - .iter() - .find(|(k, _)| k.eq_ignore_ascii_case("content-type")) - .map(|(_, v)| v.clone()) - .unwrap_or_default(); + let ct = headers.iter().find(|(k, _)| k.eq_ignore_ascii_case("content-type")).map_or_default(|(_, v)| v.clone()); assert!(ct.starts_with("text/plain"), "a scraper wants text/plain, got {ct}"); } @@ -306,12 +277,9 @@ fn backup_is_a_consistent_single_file_that_reopens_and_matches() { assert_eq!(releases, 1); drop(probe); - let mode: String = env - .db - .read(|c| Ok(c.query_row("PRAGMA journal_mode", [], |r| r.get::<_, String>(0))?)) - .unwrap(); + let mode: String = env.db.read(|c| Ok(c.query_row("PRAGMA journal_mode", [], |r| r.get::<_, String>(0))?)).unwrap(); assert_eq!(mode.to_lowercase(), "wal", "the live db should still be WAL"); - assert!(env.query_i64("SELECT count(*) FROM approval", &[]) == Some(1)); + assert_eq!(env.query_i64("SELECT count(*) FROM approval", &[]), Some(1)); } #[test] |
