Repository navigation
Commit f0ecc9b
committed
fix(types): stop the user-config tests writing to the real home directory
`test_user_config_save_and_load` called `UserConfig::save()`, which writes
`~/.lash/config.toml` on the developer's machine. It restored afterwards
with `UserConfig::default().save()`, which was wrong twice over: on the
happy path it replaced whatever the user actually had with defaults, and
if the test panicked or the process was killed the restore never ran at
all, leaving `color_scheme = "Test Theme"` behind. No theme resolves that
name, so every later `lash` invocation on the machine failed with
`Color scheme 'Test Theme' not found`.
A mutation-testing run surfaced this on 2026-08-09 by killing the suite
mid-execution hundreds of times, but any interrupted `cargo test` does
the same.
`load_from(path)` and `save_to(path)` now take the config path explicitly;
`load()` and `save()` are thin wrappers that pass the home-directory path.
The tests point at a `TempDir` and never resolve `$HOME`. Also covered:
saving into a directory that does not exist yet, and rejecting invalid
TOML on load.
`test_user_config_load_nonexistent` no longer carries its "assumes
~/.lash/config.toml doesn't exist or is valid" caveat, since it now reads
a path it created.
Audited the rest of the workspace for the same pattern. lash-cli's
`Config::user_config_path` resolves a different location (`dirs::config_dir`)
and its test only inspects the path. lash-tui's `apply_selected_theme`
calls `save()` for real, which is correct, and no test exercises it.1 parent e52c355 commit f0ecc9b
1 file changed
Lines changed: 66 additions & 27 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
332 | 332 | | |
333 | 333 | | |
334 | 334 | | |
335 | | - | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
336 | 347 | | |
337 | 348 | | |
338 | 349 | | |
| |||
366 | 377 | | |
367 | 378 | | |
368 | 379 | | |
369 | | - | |
370 | | - | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
371 | 393 | | |
372 | 394 | | |
373 | | - | |
374 | | - | |
375 | | - | |
376 | | - | |
377 | | - | |
378 | | - | |
379 | | - | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
380 | 404 | | |
381 | 405 | | |
382 | 406 | | |
| |||
718 | 742 | | |
719 | 743 | | |
720 | 744 | | |
721 | | - | |
722 | | - | |
723 | | - | |
724 | | - | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
725 | 752 | | |
726 | 753 | | |
727 | 754 | | |
728 | 755 | | |
729 | | - | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
730 | 759 | | |
731 | 760 | | |
732 | 761 | | |
733 | 762 | | |
| 763 | + | |
734 | 764 | | |
735 | | - | |
736 | | - | |
737 | | - | |
738 | | - | |
739 | | - | |
740 | | - | |
741 | | - | |
| 765 | + | |
742 | 766 | | |
743 | | - | |
744 | | - | |
745 | | - | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
746 | 786 | | |
747 | | - | |
748 | | - | |
| 787 | + | |
749 | 788 | | |
750 | 789 | | |
0 commit comments