Skip to content

Fix consistency and add tests#33

Merged
jcleigh merged 44 commits intomainfrom
fix-consistency-add-tests
Jan 8, 2026
Merged

Fix consistency and add tests#33
jcleigh merged 44 commits intomainfrom
fix-consistency-add-tests

Conversation

@jcleigh
Copy link
Collaborator

@jcleigh jcleigh commented Jan 8, 2026

This pull request adds comprehensive test coverage for the CLI commands related to repository management in the FoundAgent project. The new tests cover a wide range of scenarios for adding, removing, and reconciling repositories, ensuring correct behavior for both normal and edge cases, as well as validating output in both human-readable and JSON formats.

CLI Add Command Tests:

  • Adds tests for the add command, covering scenarios such as invalid URLs, name inference, force-adding with existing directories, handling multiple URLs, running in and outside workspaces, and both human and JSON output modes. Many edge and error cases are exercised, including skipped and failed repository additions. [1] [2]

CLI Remove Command Tests:

  • Introduces tests for the remove command, including removal of existing and non-existent repositories, config-only removal, running outside a workspace, and output validation in both human and JSON formats.

CLI Reconcile Command Tests:

  • Adds tests for the reconcile functionality, verifying behavior when all repositories are up-to-date, when repositories need to be cloned, and output in both human and JSON modes.

Main Command Tests:

  • Adds basic tests for the main binary, checking the --help and --version flags and verifying the package structure.

- Implement tests for CheckForUpdate function to verify behavior for different version scenarios including success, dev version, unknown version, and timeout.
- Introduce tests for GithubRelease struct to ensure proper JSON unmarshalling.
- Enhance version tests to check output string for both dev and release versions.
- Create tests for workspace removal functions, ensuring repositories can be added and removed correctly from state and configuration.
- Add tests for repository management functions, including checking existence and retrieval of repositories.
- Implement tests for workspace status retrieval, including scenarios with cloned repositories and worktrees.
- Validate workspace name and path length with comprehensive test cases.
- Introduce parallel execution tests to ensure correct handling of multiple repositories.
- Add tests for worktree management, verifying existence and retrieval of worktrees.
Copilot AI review requested due to automatic review settings January 8, 2026 13:37
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 pull request adds comprehensive test coverage for workspace synchronization operations, state management, and CLI worktree commands in the FoundAgent project. The tests cover sync operations (pull, push, fetch), state file handling, repository management, and CLI switch/remove commands with both normal and edge case scenarios.

Key changes:

  • Added extensive test coverage for workspace sync operations including pull, push, and status detection
  • Implemented tests for state file persistence, loading, and error handling
  • Added tests for repository removal and worktree management
  • Enhanced test coverage for version checking and update functionality
  • Fixed workspace file consistency checking to properly handle repository paths

Reviewed changes

Copilot reviewed 95 out of 102 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
internal/workspace/sync_test.go Tests for sync summary calculation, result formatting, and basic sync operations
internal/workspace/sync_status_test.go Tests for pull/push operations with various states and error conditions
internal/workspace/sync_real_test.go Integration tests using real git repositories for detached HEAD, dirty worktrees, and conflicts
internal/workspace/sync_extended_test.go Extended tests for sync operations with verbose mode and edge cases
internal/workspace/sync_coverage_test.go Additional coverage tests for pull/push operations and workspace creation
internal/workspace/status_test.go Tests for workspace status retrieval and validation
internal/workspace/state_test.go Tests for state file loading, saving, and round-trip persistence
internal/workspace/state_coverage_test.go Additional state management tests including error scenarios
internal/workspace/repository_test.go Tests for repository path generation and management operations
internal/workspace/removal_test.go Tests for repository removal from state, config, and workspace files
internal/workspace/removal_coverage_test.go Comprehensive removal operation tests with error handling
internal/workspace/removal.go Fixed config load/save to use workspace path instead of config path
internal/workspace/push_coverage_test.go Tests for push operations with various repository states
internal/workspace/pull_coverage_test.go Comprehensive pull operation tests including stash scenarios
internal/workspace/create_coverage_test.go Tests for workspace creation with error conditions
internal/workspace/config_test.go Tests for deprecated SaveConfig functionality
internal/version/version_test.go Enhanced version string tests for dev and release versions
internal/version/update_test.go Basic update checking tests with mock server scenarios
internal/version/update_mock_test.go Comprehensive mock server tests for update checking
internal/version/update_coverage_test.go Additional update check tests with version comparison
internal/version/update.go Made ReleaseURL variable for testability
internal/output/json_test.go Tests for JSON output formatting and error handling
internal/git/worktree_test.go Tests for git worktree operations (add, remove, list)
internal/git/worktree.go Fixed worktree list parsing to use strings.Split instead of filepath.SplitList
internal/git/status_test.go Tests for git status detection and file tracking
internal/git/stash_test.go Tests for git stash operations
internal/git/remote_test.go Tests for git remote operations (fetch, pull, push)
internal/git/coverage_test.go Additional git operation tests
internal/git/clone_test.go Tests for git clone operations
internal/git/branch_test.go Tests for git branch operations
internal/errors/error_test.go Tests for error wrapping and unwrapping
internal/doctor/worktrees_test.go Tests for worktree integrity checks
internal/doctor/repos_test.go Tests for repository integrity checks
internal/doctor/fix_test.go Tests for automatic fix functionality
internal/doctor/consistency_test.go Tests for workspace file consistency checking
internal/doctor/consistency.go Fixed worktree path parsing in consistency checks
internal/doctor/checks_test.go Tests for various health checks
internal/config/template_test.go Tests for config template operations
internal/config/config_test.go Additional config tests for error handling
internal/cli/wt_switch_test.go Tests for worktree switch command
internal/cli/wt_switch_run_test.go Additional switch command tests
internal/cli/wt_remove_validation_test.go Validation tests for remove command
internal/cli/wt_remove_test.go Tests for worktree remove command

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

@jcleigh
Copy link
Collaborator Author

jcleigh commented Jan 8, 2026

@copilot address PR comments

Copy link
Contributor

Copilot AI commented Jan 8, 2026

@jcleigh I've opened a new pull request, #34, to work on those changes. Once the pull request is ready, I'll request review from you.

Copilot AI and others added 17 commits January 8, 2026 15:25
…checker

Co-authored-by: jcleigh <12815554+jcleigh@users.noreply.github.com>
Address PR review comments: fix path parsing safety and improve dependency injection
- Fix gofmt formatting across test files
- Fix ineffassign issues in doctor_test.go and remote_test.go
- Update .golangci.yml to exclude goconst from test files
- Add exclusions for status strings and doctor check names
- Add gocyclo exclusion for consistency.go
- Add explicit fetch before pull in TestPull
- Add explicit push to 'origin main' instead of just 'push'
- Add verification that remote has the commit before proceeding
- Add verification that origin/main is updated after fetch
- Add better error output for debugging CI failures
When cloning from bare repo, different systems may default to different
branch names. Use 'git checkout -B main origin/main' to ensure the
cloned repo is on the main branch before making commits and pushing.
- Change Go version from 1.25 (doesn't exist) to 1.23
- Configure git init.defaultBranch=main on all OSes, not just Windows
- Set HEAD in bare repo to point to main after push (ensures clones default to main)
- Add global git user.email and user.name config for CI
- Skip TestSaveYAML_InvalidPath on Windows (path handling differs)
- Skip TestCreate_PermissionDeniedOnWorkspaceDir on Windows (permission model differs)
- Fix WorkspaceFileConsistencyCheck to normalize path separators using filepath.ToSlash()
  before parsing (Windows uses backslashes but workspace files use forward slashes)
- Add 'windows' to goconst exclusion list
Tests that use os.Chmod to simulate permission errors don't work on Windows
because Windows uses a different permission model (ACLs vs Unix permissions).

Skipped tests:
- TestCreate_StateError
- TestCreateReposStructure_PermissionDenied
- TestRemoveRepo_RemoveConfigError
- TestRemoveRepo_RemoveWorktreesError
- TestRemoveRepo_BareCloneDeleteError
- TestRemoveRepo_UpdateWorkspaceFileError
- TestAddRepository_ForceRemoveError
1. fixWorkspaceFileConsistency: Use forward slashes for VS Code workspace
   file paths instead of filepath.Join (which uses backslashes on Windows).
   VS Code workspace files always use forward slashes regardless of OS.

2. FindWorktree: Use absolute paths with symlink resolution for reliable
   path comparison. Also ensure proper prefix matching with separator.
@jcleigh jcleigh merged commit 4d3a593 into main Jan 8, 2026
5 checks passed
@jcleigh jcleigh deleted the fix-consistency-add-tests branch January 8, 2026 21:53
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