refactored: rework weak unit tests to catch real regressions
Audit found 9 confirmed-weak unit tests plus several newly-found ones that
asserted things equivalent to themselves, returned vacuous truth, or had
assertions guarded behind conditionals that silently swallowed failure.
Changes by file:
- auth/accounts.rs: create_offline_account_fields now pins the uuid to
offline_uuid("TestPlayer") instead of !is_empty(); mutating the uuid
derivation would fail this now.
- cli/mod.rs: parses_instance_list_subcommand drills into the list
subcommand under instance rather than only verifying the instance
group exists.
- config/theme.rs: border_style_roundtrip is now an rstest covering all
four BorderStyle variants; mutating any non-Double arm is caught.
- instance/desktop.rs: removed desktop_path_returns_some (assertion was
gated behind if let Some so could pass when the function returned
None); build_content_linux* already covers the real behaviour.
- instance/launch/mod.rs: removed five predicate-only tests that
asserted serde defaulting on LaunchProfile rather than invoking the
migration predicate. Added two tests that actually call
migrate_legacy_meta_if_needed (rstest over modern/legacy arg shapes)
and migrate_legacy_loader_profile_if_needed (modern-with-inheritsFrom
early-return). Renamed build_game_args_renders_upstream_arguments,
dropping the misleading "and appends loader args" clause that the
test never covered.
- instance/loader/mod.rs: removed test_vanilla_install_noop (no
assertion at all) and test_vanilla_get_versions (asserted a hardcoded
Ok(vec!["vanilla"]) return). Replaced test_vanilla_factory with an
rstest covering all five ModLoader variants; a misordered match arm
in get_installer is caught.
- migrate.rs: removed cleanup_instance_leftovers_handles_missing_dir
(had no assertions and was redundant with
cleanup_instance_leftovers_removes_shim_and_log4j).
- net/mod.rs: removed detect_java_falls_back_to_java which asserted
!is_empty() against a function whose worst-case fallback is the
literal string "java"; structurally uncatchable.
- tui/error_buffer.rs: peek_all_returns_newest_first and
auto_assigned_ids_are_unique now tag their pushed events with a
unique substring and filter peek_all_errors to just those, so the
assertions actually fire instead of being silently skipped via
if all.len() >= 2 when shared static state interfered.
Total: net zero change in test count (deletions and parameterised
replacements roughly balance), but mutation coverage of the surviving
suite is materially stronger.
This commit is contained in:
1 parent
d2e08d818b
commit
7a9dfa850d
9 files changed
+121
-124
No files matched your search
+9
-4
@@ -172,10 +172,15 @@ pub static BORDER_STYLE: LazyLock<BorderStyle> =
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn border_style_roundtrip() {
|
||||
let style = BorderStyle::Double;
|
||||
assert_eq!(style.to_border_type(), BorderType::Double);
|
||||
// cover every BorderStyle variant. a mutation that swaps two arms of the
|
||||
// match (e.g. Rounded -> Plain) would slip past testing just one variant.
|
||||
#[rstest::rstest]
|
||||
#[case::plain(BorderStyle::Plain, BorderType::Plain)]
|
||||
#[case::rounded(BorderStyle::Rounded, BorderType::Rounded)]
|
||||
#[case::double(BorderStyle::Double, BorderType::Double)]
|
||||
#[case::thick(BorderStyle::Thick, BorderType::Thick)]
|
||||
fn border_style_roundtrip(#[case] style: BorderStyle, #[case] expected: BorderType) {
|
||||
assert_eq!(style.to_border_type(), expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in new issue
Block a user