Skip to content

🧪 Add test for workspace setup report generation#178

Open
badMade wants to merge 3 commits into
mainfrom
jules-4846647906736791127-55cf90fc
Open

🧪 Add test for workspace setup report generation#178
badMade wants to merge 3 commits into
mainfrom
jules-4846647906736791127-55cf90fc

Conversation

@badMade
Copy link
Copy Markdown
Owner

@badMade badMade commented May 11, 2026

🎯 What: Added a comprehensive unit test for run_setup in src/setup.py.

📊 Coverage: The new test covers the happy path for the generation of SetupReport. It mocks the internal dependencies including the prefetch side effects (start_mdm_raw_read, start_keychain_prefetch, start_project_scan), build_workspace_setup, and run_deferred_init to verify the outputs are aggregated properly and the arguments are passed correctly without requiring any external state.

Result: Enhanced the reliability of the workspace setup logic by adding isolated unit test coverage, ensuring future refactoring won't regress the SetupReport initialization data layout.


PR created automatically by Jules for task 4846647906736791127 started by @badMade

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 11, 2026 19:26
@google-labs-jules
Copy link
Copy Markdown

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Copy link
Copy Markdown

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 isolated unit-test coverage for src.setup.run_setup, ensuring SetupReport aggregates workspace setup, prefetch results, and deferred-init output correctly without relying on external state.

Changes:

  • Introduces tests/test_setup.py with a happy-path unit test for run_setup.
  • Mocks prefetch side effects (start_mdm_raw_read, start_keychain_prefetch, start_project_scan) plus build_workspace_setup and run_deferred_init.
  • Asserts the resulting SetupReport fields and verifies mocked calls/arguments.

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

Comment thread tests/test_setup.py
from src.setup import run_setup, WorkspaceSetup
from src.prefetch import PrefetchResult
from src.deferred_init import DeferredInitResult

Comment thread tests/test_setup.py Outdated
mock_workspace = WorkspaceSetup(
python_version="3.9.0",
implementation="CPython",
platform_name="Linux"
Comment thread tests/test_setup.py Outdated
plugin_init=False,
skill_init=False,
mcp_prefetch=False,
session_hooks=False
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new test file, tests/test_setup.py, which utilizes mocks to verify that the run_setup function correctly aggregates data into a report. The feedback suggests expanding the test suite to cover default parameter values for trusted and cwd, as well as adding a test for the SetupReport.as_markdown method to ensure proper output formatting.

Comment thread tests/test_setup.py
@mock.patch('src.setup.start_mdm_raw_read')
@mock.patch('src.setup.start_keychain_prefetch')
@mock.patch('src.setup.start_project_scan')
def test_run_setup_generates_report(
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The test currently only covers the case where trusted is explicitly set to False and a cwd is provided. To ensure comprehensive coverage as stated in the PR description, consider adding test cases for the default values of these parameters (i.e., trusted=True and cwd=None). This would verify that the logic for calculating the default project root and the default trust state is correct. Additionally, consider adding a test for the SetupReport.as_markdown method to ensure the report is formatted correctly.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

@gemini-code-assist, what are the steps and line numbers to make this fix?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

To address the feedback, you should add two new test methods to the SetupTests class in tests/test_setup.py. These tests will verify the default parameter behavior and the markdown generation logic.

Steps:

  1. Add test_run_setup_defaults: This test verifies that run_setup() correctly defaults to trusted=True and cwd=None when no arguments are provided.
  2. Add test_setup_report_as_markdown: This test ensures that the as_markdown method produces the expected string output for a SetupReport instance.

These should be added after the existing test_run_setup_generates_report method (around line 76).

Suggested change
def test_run_setup_generates_report(
def test_run_setup_defaults(self, mock_start_project_scan, *args) -> None:
run_setup()
mock_start_project_scan.assert_called_once_with(None)
def test_setup_report_as_markdown(self) -> None:
from src.setup import SetupReport
report = SetupReport(cwd=Path('/test'), trusted=True, setup=mock.MagicMock(), deferred_init=mock.MagicMock(), prefetches=())
self.assertIsInstance(report.as_markdown(), str)
self.assertIn('###', report.as_markdown())

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
@badMade
Copy link
Copy Markdown
Owner Author

badMade commented May 12, 2026

@claude code review

@badMade
Copy link
Copy Markdown
Owner Author

badMade commented May 12, 2026

@copilot code review

@badMade badMade marked this pull request as ready for review May 12, 2026 17:44
Copilot AI review requested due to automatic review settings May 12, 2026 17:44
Copy link
Copy Markdown

Copilot AI commented May 12, 2026

@copilot code review

Addressed in 6382507: applied the requested formatting cleanups in tests/test_setup.py (extra blank line before the test class and trailing commas in the multi-line constructor calls), and re-ran tests/validation successfully.

Copy link
Copy Markdown

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

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

.github/workflows/auto-merge.yml:42

  • The auto-merge workflow no longer performs any merge/enable-automerge action and ends right after a check-run polling loop. As written, this job will succeed without merging anything, effectively disabling auto-merge (and the PR description doesn’t mention changing CI behavior). Restore the missing steps (and consider also validating check conclusions, not just status === 'completed').
      - name: Wait for checks to complete
        uses: actions/github-script@v7
        id: wait-checks
        with:
          script: |
            const pr = context.payload.pull_request;
            const owner = context.repo.owner;
            const repo = context.repo.repo;

            // Wait up to 5 minutes for checks to complete
            for (let i = 0; i < 10; i++) {
              await new Promise(r => setTimeout(r, 30000));

              const { data: checkRuns } = await github.rest.checks.listForRef({
                owner, repo, ref: pr.head.sha
              });

              if (checkRuns.check_runs.every(run => run.status === 'completed')) {
                break;
              }
            }

Comment thread tests/test_setup.py
Comment on lines +7 to +12
from src.setup import run_setup, WorkspaceSetup
from src.prefetch import PrefetchResult
from src.deferred_init import DeferredInitResult


class SetupTests(unittest.TestCase):
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