Skip to content

Used Claude Code to increase test coverage#82

Open
HarryStrandJamf wants to merge 21 commits intomainfrom
Use-Claude-Code-to-increase-test-coverage
Open

Used Claude Code to increase test coverage#82
HarryStrandJamf wants to merge 21 commits intomainfrom
Use-Claude-Code-to-increase-test-coverage

Conversation

@HarryStrandJamf
Copy link
Contributor

No description provided.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a broad set of unit tests across Utility/Model/Multipart components and makes small refactors to improve testability (notably TemporaryFileManager and test mocks).

Changes:

  • Add new unit tests for XML error parsing, temporary file management, file hashing, command-line processing, upload time formatting, and multiple model behaviors.
  • Refine test doubles (MockFileManager, MockDistributionPoint) to better emulate production behavior during tests.
  • Refactor TemporaryFileManager to support FileManager injection for testability; add repo “agent/assistant” guidance files.

Reviewed changes

Copilot reviewed 14 out of 19 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
JamfSyncTests/Utility/XmlErrorParserTests.swift Adds unit tests for XmlErrorParser behavior.
JamfSyncTests/Utility/TemporaryFileManagerTests.swift Adds unit tests validating temp directory creation/moves/cleanup via a mock file manager.
JamfSyncTests/Utility/FileManagerMoveRetainingPermissionsTests.swift Adds integration-style tests around FileManager.moveRetainingDestinationPermisssions.
JamfSyncTests/Utility/FileHashTests.swift Adds tests for SHA-512 hashing and Data.hexEncodedString().
JamfSyncTests/Utility/CommandLineProcessingTests.swift Adds tests for command-line sync setup and argument combinations using mock data model/persistence.
JamfSyncTests/Multipart/UploadTimeTests.swift Adds tests for formatted elapsed time strings.
JamfSyncTests/Model/SynchronizeTaskTests.swift Adds tests for orchestration logic across sync steps and error paths.
JamfSyncTests/Model/Jcds2DpTests.swift Adds tests for JCDS file list retrieval/parsing and failure paths.
JamfSyncTests/Model/FolderDpTests.swift Adds tests for local folder DP listing/deletion/transfer behavior.
JamfSyncTests/Model/FileShareDpTests.swift Adjusts an existing test to better control fileExists behavior via the mock.
JamfSyncTests/Model/DistributionPointTests.swift Adds tests for size conversion helpers and modifies transfer-local-files assertions (currently includes debug output).
JamfSyncTests/Mocks/MockFileManager.swift Extends mock with a configurable fileExists(atPath:isDirectory:) provider.
JamfSyncTests/Mocks/MockDistributionPoint.swift Updates mock transfer behavior to advance SynchronizationProgress like production.
JamfSync/Utility/TemporaryFileManager.swift Injects FileManager for testability and uses it for existence checks.
CLAUDE.md Adds AI-assistant usage guidance for the repo.
AGENTS.md Adds repository structure/style guidelines.
.claude/settings.local.json Adds Claude local settings (contains machine-specific paths).
Comments suppressed due to low confidence (2)

JamfSyncTests/Model/FileShareDpTests.swift:413

  • The fileExistsResponseProvider setup here won’t affect the .zip existence check performed by DistributionPoint.isAcceptableForDp, because that code calls fileExists(atPath:) (without isDirectory:). Unless the mock’s fileExists(atPath:) also consults fileExistsResponseProvider, this test can still filter out .pkg files unexpectedly. Fix by updating MockFileManager.fileExists(atPath:) to delegate to the provider (or adjust the test to configure fileExistsResponse appropriately).
    JamfSyncTests/Model/DistributionPointTests.swift:667
  • This test includes debug print(...) statements and comments out the original log assertion. Printing in unit tests creates noisy output and the commented assertion suggests the test is in a temporary/debug state. Please remove the prints and re-enable an assertion that verifies the intended behavior (e.g., expected log message) so failures are actionable.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

HarryStrandJamf and others added 4 commits March 19, 2026 10:36
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
mjKosmic
mjKosmic previously approved these changes Mar 20, 2026
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR focuses on increasing automated test coverage across Jamf Sync by adding new unit tests, improving testability of a few utility components, and introducing CI to run tests with code coverage reporting.

Changes:

  • Added a broad set of new unit tests for utility and model components (hashing, temp files, command line processing, DPs, sync task).
  • Refactored utility/mocks to support deterministic testing (DI for TemporaryFileManager, enhanced MockFileManager, progress updates in MockDistributionPoint).
  • Added a GitHub Actions workflow to run tests and publish coverage, and updated Xcode project structure to include new files.

Reviewed changes

Copilot reviewed 15 out of 21 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
JamfSyncTests/Utility/XmlErrorParserTests.swift New tests for XmlErrorParser parsing paths and error handling
JamfSyncTests/Utility/TemporaryFileManagerTests.swift New tests covering temp dir creation, moves, and cleanup behaviors
JamfSyncTests/Utility/FileManagerMoveRetainingPermissionsTests.swift New integration-style tests for moveRetainingDestinationPermisssions
JamfSyncTests/Utility/FileHashTests.swift New tests for SHA-512 hashing and Data.hexEncodedString()
JamfSyncTests/Utility/CommandLineProcessingTests.swift New tests for CLI processing using mocked model/persistence
JamfSyncTests/Multipart/UploadTimeTests.swift New tests for human-readable upload duration formatting
JamfSyncTests/Model/SynchronizeTaskTests.swift New tests for sync orchestration and cancellation behavior
JamfSyncTests/Model/Jcds2DpTests.swift New tests for JCDS2 file list retrieval and error cases
JamfSyncTests/Model/FolderDpTests.swift New tests for local folder DP file listing and transfers
JamfSyncTests/Model/FileShareDpTests.swift Adjusted an existing test to control fileExists behavior via mock
JamfSyncTests/Model/DistributionPointTests.swift Added tests around file sizing + modified transfer-local-files assertions/debug
JamfSyncTests/Mocks/MockFileManager.swift Added fileExistsResponseProvider to customize mock responses per path
JamfSyncTests/Mocks/MockDistributionPoint.swift Updated mock transfer to update progress like production implementation
JamfSync/Utility/TemporaryFileManager.swift Added FileManager injection for testability
JamfSync/Utility/FileHash.swift Adjusted stream creation/open handling for hashing
Jamf Sync.xcodeproj/xcshareddata/xcschemes/Jamf Sync.xcscheme Updated Xcode scheme metadata (LastUpgradeVersion)
Jamf Sync.xcodeproj/project.pbxproj Added new test files to project, reorganized groups, updated build settings
CLAUDE.md Added Claude Code contributor instructions
AGENTS.md Added repository guidelines and conventions summary
.gitignore Added ignores for local env/config/secrets-style files
.github/workflows/tests.yml New CI workflow to run tests and publish code coverage summary
Comments suppressed due to low confidence (3)

JamfSync/Utility/TemporaryFileManager.swift:18

  • fileManager is initialized once via DI and never reassigned; making it a let (and possibly private let) would better communicate immutability and reduce accidental mutation.
    JamfSyncTests/Model/DistributionPointTests.swift:664
  • These print statements will spam CI logs and aren’t asserting behavior. Prefer removing the debug output and relying on assertions (or use XCTContext.runActivity / XCTFail details if you need diagnostics only on failure).
    JamfSyncTests/Model/DistributionPointTests.swift:667
  • The original assertion verifying the completion log message is commented out, which reduces coverage for the user-visible behavior this test used to validate. Either restore the log assertion (and fix underlying flakiness) or replace it with an equivalent verification that the same success path occurred.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

HarryStrandJamf and others added 4 commits March 20, 2026 16:35
….swift

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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.

3 participants