Skip to content

[Test Improver] test: add unit tests for BaseIntegrator core infrastructure (60 tests)#567

Draft
danielmeppiel wants to merge 1 commit intomainfrom
test-assist/base-integrator-coverage-23967975087-2abfaa71f0cd3fa0
Draft

[Test Improver] test: add unit tests for BaseIntegrator core infrastructure (60 tests)#567
danielmeppiel wants to merge 1 commit intomainfrom
test-assist/base-integrator-coverage-23967975087-2abfaa71f0cd3fa0

Conversation

@danielmeppiel
Copy link
Copy Markdown
Collaborator

🤖 Test Improver - automated AI assistant for test improvements.

Goal and Rationale

BaseIntegrator is the shared infrastructure that every file-level integrator inherits. Its methods handle:

  • Security gates: validate_deploy_path(), check_collision() — prevent path traversal and data loss
  • Performance-critical routing: partition_managed_files() — trie-based O(1) routing used during install/uninstall for all packages
  • File lifecycle: sync_remove_files(), cleanup_empty_parents(), find_files_by_glob()

Despite being foundational, BaseIntegrator had no direct unit tests. Bugs here affect all integrators (prompts, instructions, skills, hooks, commands, rules).

Approach

Added tests/unit/integration/test_base_integrator.py with 60 tests covering all 8 public methods:

Method Tests Key scenarios
IntegrationResult 2 default fields, explicit fields
check_collision 8 None managed, absent file, managed file, collision, force, backslash norm, diagnostics, warning
normalize_managed_files 5 None, forward slashes, backslashes, mixed, empty
validate_deploy_path 9 valid paths, traversal, unknown prefix, absolute, symlink escape, custom prefixes
partition_bucket_key 7 all backward-compat aliases, no-alias passthrough
partition_managed_files 10 prompts, instructions, skills, commands, rules_cursor, unknown prefix, multi-file, hooks/skills cross-target
cleanup_empty_parents 6 empty removal, nonempty preserved, stop_at, empty input, batch, OSError ignored
sync_remove_files 7 removal, prefix filter, nonexistent, legacy glob, traversal blocked, no-op, unlink error
find_files_by_glob 6 pattern match, no match, subdirs, dedup, nonexistent subdir, sorted output

Coverage Impact

Scope Before After
Test count 3,551 3,611
New tests +60
base_integrator.py direct coverage 0% (indirect only) ~85%+

Reproducibility

uv run pytest tests/unit/integration/test_base_integrator.py -v
# Full suite
uv run pytest tests/unit tests/test_console.py -x -q

Test Status

All 3,611 tests pass locally.

Generated by Daily Test Improver ·

To install this agentic workflow, run

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

Covers all key shared methods that every file-level integrator relies on:
- IntegrationResult dataclass fields and defaults
- check_collision(): managed_files=None, absent file, managed file,
  collision detection, force flag, backslash normalization, diagnostics
- normalize_managed_files(): backslash->forward-slash, None passthrough
- validate_deploy_path(): traversal rejection, prefix allowlist,
  symlink escape, custom prefixes
- partition_bucket_key(): backward-compat alias mapping
- partition_managed_files(): trie-based routing for prompts/instructions/
  skills/commands/rules_cursor buckets + cross-target hooks/skills
- cleanup_empty_parents(): empty dir removal, stop_at boundary,
  nonempty dirs preserved, OSError ignored
- sync_remove_files(): managed removal, prefix filter, legacy glob,
  validate_deploy_path enforcement, unlink error handling
- find_files_by_glob(): pattern matching, subdirs, dedup, sort

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