Skip to content

[#121] Add sandbox tests for core doctor checks#257

Closed
bguidolim wants to merge 2 commits intobruno/121-doctor-environment-injectionfrom
bruno/121-doctor-check-sandbox-tests
Closed

[#121] Add sandbox tests for core doctor checks#257
bguidolim wants to merge 2 commits intobruno/121-doctor-environment-injectionfrom
bruno/121-doctor-check-sandbox-tests

Conversation

@bguidolim
Copy link
Collaborator

Summary

Add sandbox tests for all core doctor check structs that were made injectable in PR #256. Each test creates a temp directory, constructs Environment(home: tmpDir), and verifies check behavior against controlled file fixtures — no real ~/ paths are touched.

Stacked on #256 (PR 1 of the #121 series).

Changes

  • Add CoreDoctorCheckSandboxTests.swift with 23 tests across 5 suites:
    • MCPServerCheckSandboxTests (5 tests): global/project-scoped servers, missing server, missing file, invalid JSON
    • PluginCheckSandboxTests (3 tests): enabled/not-enabled plugin, missing settings
    • HookCheckSandboxTests (6 tests): present+executable, missing, optional skip, not-executable, fix makes executable, fix when missing
    • ProjectIndexCheckSandboxTests (5 tests): all paths valid, stale paths, empty index, fix prunes stale, global sentinel
    • DerivedDoctorCheckSandboxTests (4 tests): copyPackFile global URL, copyPackFile with project root + fallback, mcpServer uses env, allDoctorChecks forwards env

Test plan

  • swift test passes locally (758 tests, only pre-existing 1Password SSH agent failures in PackFetcher/PackUpdater)
  • swiftformat --lint . and swiftlint pass without violations
  • Affected commands verified with a real pack (e.g. mcs sync, mcs doctor)

- Add 23 tests across 5 suites verifying doctor checks work correctly
  with injected Environment(home: tmpDir)
- Cover MCPServerCheck, PluginCheck, HookCheck, ProjectIndexCheck,
  and DerivedDoctorChecks with full sandbox isolation
- Verify check/fix behavior for pass, fail, warn, skip, and fix paths
- Add `commit.gpgsign=false` to test repo config in PackFetcherTests
  and PackUpdaterTests to prevent 1Password SSH agent interference
- Fix ambiguous #require assertion in CoreDoctorCheckSandboxTests
@bguidolim bguidolim force-pushed the bruno/121-doctor-check-sandbox-tests branch from 502603f to cd19612 Compare March 21, 2026 15:40
@bguidolim bguidolim deleted the branch bruno/121-doctor-environment-injection March 21, 2026 15:43
@bguidolim bguidolim closed this Mar 21, 2026
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.

1 participant