testsAndMisc/linux_configuration/scripts/periodic_background
Krzysztof kuhy Rudnicki 63454fa544 install_leechblock: first test suite for the split libs
29 assertions across two files, run via lib/tests/run_all.sh.

Coverage measured, not waived: leechblock_fetch.sh 38.57% (27/70),
leechblock_browsers.sh 36.47% (31/85), config and firefox 0%. The uncovered
lines are exactly the bodies that must never run under test — curl/tar/unzip
downloads, pkill + sudo binary patching, npm install, and writes to
/etc/*/policies.json. Closing the gap needs those externals shimmed.

What the tests actually pin down:
- all three get_latest_tag fallbacks (releases API, tags API, Location
  header), plus JSON-null-is-not-a-tag and the all-sources-exhausted
  non-zero return. A silent failure there installs the wrong version.
- the 8+3 browser tables including every hyphenated key, and the
  command -v gating that decides whether a binary is patched at all.

Also fixes a latent set -u abort: wire_up_browsers interpolates VERSION_DIR,
VERSION and TAG, which only resolve_version sets. Calling it on its own
aborted on an unbound VERSION_DIR; they are now read through locals with
defaults, leaving production output unchanged.

Harness note: PATH must be narrowed to the shim dir for "no browser
installed" to be testable on a machine that has five, but every external the
code under test calls has to be seeded there too — a missing mkdir aborted
the suite under set -e with no stderr, which under kcov looked like a
coverage-tool bug rather than a PATH bug.

The hyphenated array subscripts in the test are quoted for the same reason
they are in the lib: shfmt -w rewrites an unquoted [google-chrome-stable]
into a subtraction expression. Reproduced live in this file during the work.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01F3PzGc75gBcdxP3PkHXGcV
2026-08-21 15:39:15 +02:00
..
digital_wellbeing install_leechblock: first test suite for the split libs 2026-08-21 15:39:15 +02:00
hosts hosts/install: split into lib/ under the 250-line cap 2026-08-21 14:45:04 +02:00
i3-configuration i3blocks: add Claude usage block, fix icon rendering, drop dead blocks 2026-08-10 15:14:34 +02:00
lib check_and_enable_services: a warning must never mask an error 2026-08-21 14:16:01 +02:00
system-maintenance usage_report: delete the dead _compute_window shim 2026-08-17 12:57:52 +02:00
utils Fail the build on any shellcheck finding; fix the 222 the old gate hid 2026-08-03 19:49:11 +02:00
check_and_enable_services.sh check_and_enable_services: 100% coverage via a redirectable path prefix 2026-08-21 14:08:11 +02:00
setup_periodic_system.sh Split two more linux_configuration scripts; revert a third 2026-08-16 18:44:18 +02:00