Skip to content

test: smoke tests for update.py pure functions (Phase 2 updater)#19

Open
bipinhcs11 wants to merge 1 commit into
mainfrom
test/update-pure-functions
Open

test: smoke tests for update.py pure functions (Phase 2 updater)#19
bipinhcs11 wants to merge 1 commit into
mainfrom
test/update-pure-functions

Conversation

@bipinhcs11
Copy link
Copy Markdown
Owner

Summary

update.py — the Phase 2 incremental updater — had zero test coverage despite being the critical path for keeping skills current after every code change. This PR adds tests/test_update.py with 31 stdlib-only smoke tests covering all pure functions.

Functions covered:

Function Cases
_bump_version normal bump, no-space colon, indented field (fallback), missing field (fallback), large number, multiple fields (first wins)
_domain_from_skill Java class extraction, XML/SQL/shell extraction, lowercase-guard, id/name assignment, empty input
_map_files_to_features exact match, no-match, file shared by two features → mapped to both, empty list, non-existent skills dir
ingest_responses (commit=False) correct version bump, force-bump when AI forgets to increment, last_updated forced to today, fenced response unwrapped, empty response → failed, missing response file → failed, missing SKILL.md → failed, no skills dir → early return

Key regression pinned by these tests: when the AI response omits a version bump (returns version: 3 when the existing file was already version: 3), ingest_responses must still write version: 4. The re.sub in the ingest path handles this correctly and the test now guards against accidental removal.

Test plan

python3 -m unittest tests/test_update.py -v   # 31 passed, 0 failed
python3 -m unittest discover tests/          # 203 passed, 0 failed (up from 172)

Follow-ups (not in this PR)

  • cli.py also has no direct tests; integration-level tests for build_parser() and the _cmd_* dispatch functions would catch argument wiring bugs.
  • _git_changed_files is not tested here because it calls subprocess directly; mocking subprocess is out of scope for stdlib-only smoke tests.

https://claude.ai/code/session_01Ky9BS6ZwmrR437WUcEXvD6


Generated by Claude Code

update.py (Phase 2 incremental updater) had zero test coverage despite
being the critical path for keeping skills current after each code
change. Adds tests/test_update.py covering:

  - _bump_version: normal bump, no-space colon, indented field fallback,
    missing field fallback, large version, multiple fields (first wins)
  - _domain_from_skill: class/XML/SQL/shell extraction, lowercase guard,
    id/name assignment, empty-input safety
  - _map_files_to_features: exact match, no-match, file shared by two
    features (mapped to both), empty changed-files list, non-existent
    skills directory
  - ingest_responses (commit=False): correct version bump, force-bump
    when AI forgets to increment, last_updated forced to today, fenced
    response unwrapped, empty response → failed, missing response →
    failed, missing SKILL.md → failed, no skills dir → early return

31 new tests; full suite: 203 passed, 0 failed.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

https://claude.ai/code/session_01Ky9BS6ZwmrR437WUcEXvD6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants