Add integration tests for DevPullCommand - #19
Conversation
Co-authored-by: sak0a <24781653+sak0a@users.noreply.github.com>
Co-authored-by: sak0a <24781653+sak0a@users.noreply.github.com>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
There was a problem hiding this comment.
Pull request overview
Adds integration test coverage for the notur:dev:pull Artisan command and introduces a small DI hook so HTTP calls can be mocked during tests.
Changes:
- Added
DevPullCommandTest.phpwith integration tests covering dry-run behavior, commit info display, error handling, and custom repo config. - Updated
DevPullCommandto accept an optionalGuzzleHttp\Clientvia constructor for testability.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
tests/Integration/Console/DevPullCommandTest.php |
New integration tests for notur:dev:pull, including mocked GitHub API responses. |
src/Console/Commands/DevPullCommand.php |
Adds optional constructor injection for Client and uses it when present. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| protected function setUp(): void | ||
| { | ||
| parent::setUp(); | ||
| $this->loadMigrationsFrom(__DIR__ . '/../../../database/migrations'); | ||
| } |
There was a problem hiding this comment.
These tests invoke notur:dev:pull, but the command exits early unless base_path('vendor/notur/notur') exists and is writable. The test setup doesn’t currently create that directory, so the tests will fail before hitting the mocked HTTP client. Create the directory (and ensure it’s writable) in setUp() and clean it up in tearDown() (or use a temporary base path override if your testbench setup supports it).
| $this->artisan('notur:dev:pull', ['--dry-run' => true]) | ||
| ->expectsOutput('[DRY RUN] Would download and extract commit abc123de to ' . base_path('vendor/notur/notur')) | ||
| ->expectsOutput('[DRY RUN] Would rebuild frontend bridge') | ||
| ->expectsOutput('[DRY RUN] Would copy bridge.js and tailwind.css to public/notur/') | ||
| ->assertExitCode(0); |
There was a problem hiding this comment.
expectsOutput() is order-sensitive in Laravel/Orchestra console testing; this command prints several lines ("Fetching commit info…", commit details, warnings) before the [DRY RUN] … lines. As written, the first expectsOutput('[DRY RUN] …') is likely to fail because it won’t be the first output line. Prefer expectsOutputToContain() for these assertions, or assert the full ordered output including the preceding lines.
| ->expectsOutput(' Branch: develop') | ||
| ->expectsOutput(' Commit: abc123de') | ||
| ->expectsOutput(' Author: Jane Developer') | ||
| ->expectsOutput(' Date: 2024-01-15T10:30:00Z') | ||
| ->expectsOutput(' Message: Add new feature') |
There was a problem hiding this comment.
Similar to the dry-run assertions: the command outputs additional lines before the commit info block (e.g. "Fetching commit info…") and also outputs warnings after it. If expectsOutput() is used here, ensure the expected lines match the actual ordered output, or switch these to expectsOutputToContain() to avoid brittle ordering failures.
| ->expectsOutput(' Branch: develop') | |
| ->expectsOutput(' Commit: abc123de') | |
| ->expectsOutput(' Author: Jane Developer') | |
| ->expectsOutput(' Date: 2024-01-15T10:30:00Z') | |
| ->expectsOutput(' Message: Add new feature') | |
| ->expectsOutputToContain(' Branch: develop') | |
| ->expectsOutputToContain(' Commit: abc123de') | |
| ->expectsOutputToContain(' Author: Jane Developer') | |
| ->expectsOutputToContain(' Date: 2024-01-15T10:30:00Z') | |
| ->expectsOutputToContain(' Message: Add new feature') |
The
notur:dev:pullcommand lacked test coverage despite existing integration tests for other Artisan commands.Changes
Added
DevPullCommandTest.phpwith 8 integration tests covering:--dry-runexecution path (with/without--no-rebuild)Modified
DevPullCommandto support dependency injection:Clientconstructor parameter for test mockingImplementation
Tests use Mockery to mock GitHub API responses, avoiding real HTTP calls:
Follows patterns from existing integration tests in
tests/Integration/Console/.✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.