Skip to content

[Test Improver] test: add unit tests for BaseIntegrator utility methods#585

Draft
danielmeppiel wants to merge 1 commit intomainfrom
test-assist/base-integrator-utils-24014638607-ff62256783ba614b
Draft

[Test Improver] test: add unit tests for BaseIntegrator utility methods#585
danielmeppiel wants to merge 1 commit intomainfrom
test-assist/base-integrator-utils-24014638607-ff62256783ba614b

Conversation

@danielmeppiel
Copy link
Copy Markdown
Collaborator

Overview

Goal: Cover 4 BaseIntegrator utility methods that had zero direct test coverage. These methods are called by every file-level integrator (skills, prompts, hooks, agents, instructions) and are critical for correct sync behaviour across platforms.

Methods covered:

Method Purpose
normalize_managed_files() Normalise path separators for O(1) cross-platform set lookups
cleanup_empty_parents() Bottom-up directory removal after manifest sync
sync_remove_files() Manifest-based file removal + legacy glob fallback
find_files_by_glob() Package file discovery with optional subdir search

Rationale

These methods form the core of APM's install/uninstall sync pipeline. Without direct tests:

  • Regressions in cross-platform path handling (Windows backslash vs POSIX) go undetected
  • Edge cases in directory cleanup (stop_at boundary, non-empty parent preservation) are untested
  • The legacy glob fallback path in sync_remove_files has never been exercised by tests
  • Security validation inside sync_remove_files (traversal path rejection) is untested

Test cases added

TestNormalizeManagedFiles (8 tests): None passthrough, empty set, forward-slash no-op, backslash conversion, mixed separators, immutability, deduplication after normalization, large set.

TestCleanupEmptyParents (7 tests): Empty list no-op, removes empty intermediate dirs, preserves stop_at, preserves non-empty dirs, multiple files in same dir, deeply nested cleanup, boundary stop.

TestSyncRemoveFiles (9 tests): Removes matching files, skips non-prefix files, skips missing files, legacy glob fallback, missing glob dir, multiple files, traversal path rejection, invalid prefix, missing glob pattern.

TestFindFilesByGlob (8 tests): Finds matches, empty result, nonexistent dir, subdir search, deduplication across dirs, combined root+subdir, missing subdir, sorted results.

Coverage impact

Before After
normalize_managed_files 0% 100%
cleanup_empty_parents 0% 100%
sync_remove_files 0% 100%
find_files_by_glob 0% 100%
Tests total 3614 3646 (+32)

Test status

32 passed in 0.31s
3646 passed in 15.02s  # full unit suite

Reproducibility

uv run pytest tests/unit/integration/test_base_integrator_utils.py -v
uv run pytest tests/unit tests/test_console.py -x -q

🤖 Test Improver - automated AI assistant. Review before merging.

Generated by Daily Test Improver ·

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/daily-test-improver.md@b87234850bf9664d198f28a02df0f937d0447295

Cover 4 methods with zero existing tests:
- normalize_managed_files(): path sep normalization + dedup
- cleanup_empty_parents(): bottom-up dir removal after sync
- sync_remove_files(): manifest-based file removal + legacy glob fallback
- find_files_by_glob(): package file discovery with subdir support

32 new tests, all passing. No production code changed.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant