test: expand test coverage across core functions, enforce strict fish_indent linting, and add network isolation harnesses #143

Merged
rootiest merged 8 commits from test/network-edge-case-coverage into main 2026-09-10 01:00:47 +00:00
Owner

Overview

This PR significantly expands test coverage across the repository, enforces strict code formatting via fish_indent --check in the CI test runner, and implements hermetic test harnesses for network-dependent scripts and functions.

Total test assertions in tests/run-tests.fish increase from 511 to 659 (+148 assertions), with an additional 29 Python unit tests in tests/test_sync_labels.py and 76 documentation verification tests.

Key Changes

1. Network Isolation & Failure Edge Case Testing

  • tests/test_sync_labels.py (29 tests):
    • Unit tests for scripts/sync-labels.py covering simulated network drops (URLError, ConnectionRefusedError, socket.timeout), HTTP status codes (401, 403 rate limit, 404, 500, 502), pagination boundaries, malformed JSON, and dry-run mutation guards.
  • tests/test-network-fish.fish (63 assertions):
    • Hermetic mocks overriding curl, git, and bd in a temporary mock $PATH to simulate network failures without external dependencies.
    • Covers 11 utilities: gi, gip, gip4, gip6, qr, bd-pull, _auto_pull_sync, gitup, git-clean, config-update, repo-open, and fzf-update.
  • tests/test-network-python.fish (31 assertions):
    • Bridges the Python unittest suite into the fish test runner tally.

2. Stricter Linting (fish_indent --check) & Codebase Formatting

  • Formatted all 58 non-conforming .fish files in functions/, conf.d/, completions/, integrations/, tests/, and config.fish with fish_indent -w.
  • Documentation Headers Preserved 100% Intact: Verified with python3 docs/verify-manual.py (76/76 passed) and python3 docs/build-manual.py --site (produces zero diff).
  • Updated Phase 1 in tests/run-tests.fish to enforce both fish -n (syntax) and fish_indent --check across 239 files.

3. String & Commandline Expansion Test Suite (tests/test-string-and-expansion.fish)

  • 68 isolated assertions covering:
    • rand_string: curated categories (animal, color, noun, verb, adjective, name), casing (--case=upper/lower/title, -c), separators (dash, underscore, dot, none, custom delimiters), digits generation, error handling on missing categories, and help documentation.
    • _replace_command_token: commandline token replacement with and without sudo, cursor positioning.
    • __substitute_typo: history caret substitution (^old^new) vs literal caret pass-through.
    • _puffer_fish_expand_dot & _puffer_fish_expand_bang: puffer token expansion logic and search field handling.

4. Core Utilities & Security Test Suite (tests/test-core-utilities.fish)

  • 80 isolated assertions covering:
    • sponge_filter_secrets: credential detection heuristics (TOKEN, API_KEY, PASSWORD, KOPIA_PASSWORD), filtering rules (returns 0 on secret in command, 1 on clean command), minimum length threshold (>8 chars), and path exception handling (/, ~).
    • _fish_mkdir_p: parent directory creation, --path, --tree, and --silent modes, handling existing directories and empty inputs.
    • _scrollback_prune_junk: pruning empty files, single-line noise files, and Kitty tab-rename prompts while preserving genuine multi-line log sessions.
    • sudo-toggle: toggling /etc/sudoers.d/nofail-toggle between ENABLED and DISABLED via mocked sudo stat, truncate, and tee.
    • spark: sparkline rendering with number arrays, min/max bounds clamping, version, and help flags.
    • pkg: package manager detection and query fallback handling.

5. Pre-existing Bug Fixes (Cleanly Partitioned)

  • functions/sponge_filter_secrets.fish: added --entire flag to string match --regex to avoid partial variable name slicing under fish 4.x (per fish-string-set-gotchas rule).
  • docs/generate_component_registry.py: aligned registry generator output with fish_indent formatting rules to prevent generator drift.

Manual Verification Checklist

  • Full CI test suite passes: fish tests/run-tests.fish (659/659 assertions passed, 239/239 files passed syntax & indent check)
  • Python unit tests pass: python3 -m unittest tests/test_sync_labels.py -v (29/29 passed)
  • Documentation verification passes: python3 docs/verify-manual.py (76/76 passed)
  • Documentation site build produces zero diff: python3 docs/build-manual.py --site
  • No AI attribution trailers (Co-Authored-By: Claude, etc.) in commits or PR description
## Overview This PR significantly expands test coverage across the repository, enforces strict code formatting via `fish_indent --check` in the CI test runner, and implements hermetic test harnesses for network-dependent scripts and functions. Total test assertions in `tests/run-tests.fish` increase from **511** to **659** (+148 assertions), with an additional **29** Python unit tests in `tests/test_sync_labels.py` and **76** documentation verification tests. ## Key Changes ### 1. Network Isolation & Failure Edge Case Testing - **`tests/test_sync_labels.py`** (29 tests): - Unit tests for `scripts/sync-labels.py` covering simulated network drops (`URLError`, `ConnectionRefusedError`, `socket.timeout`), HTTP status codes (`401`, `403` rate limit, `404`, `500`, `502`), pagination boundaries, malformed JSON, and dry-run mutation guards. - **`tests/test-network-fish.fish`** (63 assertions): - Hermetic mocks overriding `curl`, `git`, and `bd` in a temporary mock `$PATH` to simulate network failures without external dependencies. - Covers 11 utilities: `gi`, `gip`, `gip4`, `gip6`, `qr`, `bd-pull`, `_auto_pull_sync`, `gitup`, `git-clean`, `config-update`, `repo-open`, and `fzf-update`. - **`tests/test-network-python.fish`** (31 assertions): - Bridges the Python unittest suite into the fish test runner tally. ### 2. Stricter Linting (`fish_indent --check`) & Codebase Formatting - Formatted all 58 non-conforming `.fish` files in `functions/`, `conf.d/`, `completions/`, `integrations/`, `tests/`, and `config.fish` with `fish_indent -w`. - **Documentation Headers Preserved 100% Intact**: Verified with `python3 docs/verify-manual.py` (76/76 passed) and `python3 docs/build-manual.py --site` (produces zero diff). - Updated Phase 1 in `tests/run-tests.fish` to enforce both `fish -n` (syntax) and `fish_indent --check` across 239 files. ### 3. String & Commandline Expansion Test Suite (`tests/test-string-and-expansion.fish`) - 68 isolated assertions covering: - `rand_string`: curated categories (`animal`, `color`, `noun`, `verb`, `adjective`, `name`), casing (`--case=upper/lower/title`, `-c`), separators (`dash`, `underscore`, `dot`, `none`, custom delimiters), digits generation, error handling on missing categories, and help documentation. - `_replace_command_token`: commandline token replacement with and without `sudo`, cursor positioning. - `__substitute_typo`: history caret substitution (`^old^new`) vs literal caret pass-through. - `_puffer_fish_expand_dot` & `_puffer_fish_expand_bang`: puffer token expansion logic and search field handling. ### 4. Core Utilities & Security Test Suite (`tests/test-core-utilities.fish`) - 80 isolated assertions covering: - `sponge_filter_secrets`: credential detection heuristics (`TOKEN`, `API_KEY`, `PASSWORD`, `KOPIA_PASSWORD`), filtering rules (returns 0 on secret in command, 1 on clean command), minimum length threshold (>8 chars), and path exception handling (`/`, `~`). - `_fish_mkdir_p`: parent directory creation, `--path`, `--tree`, and `--silent` modes, handling existing directories and empty inputs. - `_scrollback_prune_junk`: pruning empty files, single-line noise files, and Kitty tab-rename prompts while preserving genuine multi-line log sessions. - `sudo-toggle`: toggling `/etc/sudoers.d/nofail-toggle` between ENABLED and DISABLED via mocked `sudo stat`, `truncate`, and `tee`. - `spark`: sparkline rendering with number arrays, min/max bounds clamping, version, and help flags. - `pkg`: package manager detection and query fallback handling. ### 5. Pre-existing Bug Fixes (Cleanly Partitioned) - `functions/sponge_filter_secrets.fish`: added `--entire` flag to `string match --regex` to avoid partial variable name slicing under fish 4.x (per `fish-string-set-gotchas` rule). - `docs/generate_component_registry.py`: aligned registry generator output with `fish_indent` formatting rules to prevent generator drift. ## Manual Verification Checklist - [x] Full CI test suite passes: `fish tests/run-tests.fish` (659/659 assertions passed, 239/239 files passed syntax & indent check) - [x] Python unit tests pass: `python3 -m unittest tests/test_sync_labels.py -v` (29/29 passed) - [x] Documentation verification passes: `python3 docs/verify-manual.py` (76/76 passed) - [x] Documentation site build produces zero diff: `python3 docs/build-manual.py --site` - [x] No AI attribution trailers (`Co-Authored-By: Claude`, etc.) in commits or PR description
rootiest added the Kind/TestingArea/FunctionsArea/Tests labels 2026-09-10 00:56:41 +00:00
rootiest added 8 commits 2026-09-10 00:56:42 +00:00
rootiest merged commit 3c621db727 into main 2026-09-10 01:00:47 +00:00
rootiest deleted branch test/network-edge-case-coverage 2026-09-10 01:00:48 +00:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: rootiest/fish-config#143