Skip to content

Commit 18cc57a

Browse files
committed
lints: Fix unit tests to use RootType::Alternative
Prep for adding unit tests which hard require the running root (like tmpfiles.d) - we can't unit test those. Signed-off-by: Colin Walters <[email protected]>
1 parent efca8b2 commit 18cc57a

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

lib/src/lints.rs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ mod tests {
541541
let root = &passing_fixture()?;
542542
let mut out = Vec::new();
543543
let warnings = WarningDisposition::FatalWarnings;
544-
let root_type = RootType::Running;
544+
let root_type = RootType::Alternative;
545545
lint(root, warnings, root_type, [], &mut out).unwrap();
546546
root.create_dir_all("var/run/foo")?;
547547
let mut out = Vec::new();
@@ -553,31 +553,30 @@ mod tests {
553553
fn test_lint_inner() -> Result<()> {
554554
let root = &passing_fixture()?;
555555

556-
// Verify that all lints run except one which is skipped for non-running roots
556+
// Verify that all lints run
557557
let mut out = Vec::new();
558-
let root_type = RootType::Running;
558+
let root_type = RootType::Alternative;
559559
let r = lint_inner(root, root_type, [], &mut out).unwrap();
560-
let allbut_one = LINTS.len().checked_sub(1).unwrap();
561-
assert_eq!(r.passed, allbut_one);
560+
assert_eq!(r.passed, LINTS.len());
562561
assert_eq!(r.fatal, 0);
563-
assert_eq!(r.skipped, 1);
562+
assert_eq!(r.skipped, 0);
564563
assert_eq!(r.warnings, 0);
565564

566565
let r = lint_inner(root, root_type, ["var-log"], &mut out).unwrap();
567566
// Trigger a failure in var-log
568567
root.create_dir_all("var/log/dnf")?;
569568
root.write("var/log/dnf/dnf.log", b"dummy dnf log")?;
570-
assert_eq!(r.passed, allbut_one.checked_sub(1).unwrap());
569+
assert_eq!(r.passed, LINTS.len().checked_sub(1).unwrap());
571570
assert_eq!(r.fatal, 0);
572-
assert_eq!(r.skipped, 2);
571+
assert_eq!(r.skipped, 1);
573572
assert_eq!(r.warnings, 0);
574573

575-
// But verify that not skipping it results in an error
574+
// But verify that not skipping it results in a warning
576575
let mut out = Vec::new();
577576
let r = lint_inner(root, root_type, [], &mut out).unwrap();
578-
assert_eq!(r.passed, allbut_one.checked_sub(1).unwrap());
577+
assert_eq!(r.passed, LINTS.len().checked_sub(1).unwrap());
579578
assert_eq!(r.fatal, 0);
580-
assert_eq!(r.skipped, 1);
579+
assert_eq!(r.skipped, 0);
581580
assert_eq!(r.warnings, 1);
582581
Ok(())
583582
}

0 commit comments

Comments
 (0)