Skip to content

test: comprehensive coverage — 87 test files, 378 tests, 3% to 100%#43

Open
JoshSalway wants to merge 3 commits intolaravel:mainfrom
JoshSalway:feature/comprehensive-test-coverage
Open

test: comprehensive coverage — 87 test files, 378 tests, 3% to 100%#43
JoshSalway wants to merge 3 commits intolaravel:mainfrom
JoshSalway:feature/comprehensive-test-coverage

Conversation

@JoshSalway
Copy link

@JoshSalway JoshSalway commented Mar 16, 2026

Summary

Comprehensive test coverage for all 87 CLI commands, following the Laravel Forge CLI pattern of one test file per command. Increases coverage from 3% to 100%.

Refs #41

Context

The Laravel Forge CLI has a feature test file for every one of its 31 commands (100% coverage). The Cloud CLI previously had tests for only 3 commands. This PR closes that gap completely.

Before vs After

Metric Before After
Test files 3 87
Tests 31 378
Assertions 32 409
Command coverage 3/87 (3%) 87/87 (100%)
Duration 1s 10s

Test files added (84 new files)

Domain Test files Tests
Auth Auth, AuthToken 6
Application Create, Get, List, Update, Delete 38
Environment Create, Get, List, Update, Delete, Variables, Logs 34
Domain Create, Get, List, Update, Delete, Verify 17
Database ClusterCreate/Get/List/Update/Delete, Create/Get/List/Delete/Open 45
Database Snapshots Create, Get, List, Delete 17
Database Restore Create 2
Cache Create, Get, List, Types, Update, Delete 22
Bucket Create, Get, List, Update, Delete 20
Bucket Keys Create, Get, List, Update, Delete 29
Instance Create, Get, List, Sizes, Update, Delete 20
WebSocket Cluster Create, Get, List, Update, Delete 15
WebSocket App Create, Get, List, Update, Delete 17
Background Process Create, Get, List, Update, Delete 17
Command Get, List, Run 10
Deploy Deploy, Monitor, DeploymentGet, DeploymentList 12
Ship Full non-interactive workflow, flags, errors 6
Utility Browser, Dashboard, Completions, RepoConfig, IpAddresses, DedicatedClusterList 16

Bugs discovered during testing (14 total)

Bug Severity Issue PR
Wrong RequestException import in 7 commands Critical #50 #42
ApplicationUpdate no error handling High #51 #42
DatabaseRestoreCreate completely broken (TypeError) Critical #55 #58
Empty list returns SUCCESS in JSON mode Medium #44 #52
DomainCreate missing non-interactive defaults Medium #45 #52
DatabaseDelete catches Throwable, swallows CommandExitException Medium #46 #52
3 create commands unusable non-interactively Medium #47 #53
DatabaseSnapshotCreate missing CLI options Medium #56 #58
DatabaseClusterUpdate unusable non-interactively Medium #57 #58
CacheDelete/BucketDelete missing --json option Minor #48 #52
Method typo getWorkerDefult Minor #49 #52
BucketUpdate/BucketKeyUpdate no error handling Minor
CommandList no empty result handling Minor
Prompt::fake() limitations with password/select Testing limitation

Test patterns used

Following the Forge CLI conventions:

  • One test file per command
  • Mock API client with Saloon MockClient
  • Test happy path (interactive + with arguments)
  • Test error cases (not found, validation errors, server errors)
  • Test JSON output mode
  • Document bugs as skipped tests with references to fix PRs

Test plan

  • ./vendor/bin/pest — 378 tests, 409 assertions, 0 failures
  • ./vendor/bin/phpstan analyse — 0 errors
  • All 87 commands covered

Generated with Claude Code

Increases test coverage from 3/87 commands (~3%) to 43/87 (~49%),
following the Laravel Forge CLI pattern of one test file per command.

Commands now tested:
- Auth: auth, auth:token
- Application: create, get, update, delete
- Environment: create, get, list, update, delete, variables
- Domain: create, delete, list, verify
- Database: cluster create/delete/list, database create/delete/list
- Cache: create, delete, list
- Bucket: create, delete, list
- Instance: create, delete, list, update
- WebSocket: cluster create/delete/list, application create/delete
- Background Process: create, delete, list
- Command: run, list

Bugs documented in tests (skipped with references to PR laravel#42):
- 7 commands catch wrong RequestException class (Illuminate vs Saloon)
- ApplicationUpdate has no error handling for API failures
- DatabaseDelete catches Throwable which swallows CommandExitException
- DomainCreate missing non-interactive defaults
- CacheDelete/BucketDelete missing --json option

Refs laravel#41

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
JoshSalway and others added 2 commits March 17, 2026 03:32
…3 files

Coverage now at ~95% of commands (80/87). Remaining untested:
Browser, Dashboard, Completions (utility commands that open browser/generate shell),
Ship (tested via refactor PR laravel#54), and DeployMonitor (complex polling).

New test files cover:
- Application: list (expanded)
- BackgroundProcess: get, update
- Bucket: get, update
- BucketKey: create, delete, get, list, update
- Cache: get, types, update
- Command: get
- DatabaseCluster: get, update
- Database: get, open, restore create
- DatabaseSnapshot: create, delete, get, list
- DedicatedCluster: list
- Deployment: get, list
- DeployMonitor: basic smoke test
- Domain: get, update
- EnvironmentLogs: basic test
- Instance: get, sizes
- IpAddresses: list, filter
- AuthToken: list, reveal
- WebSocket: app get/list/update, cluster get/update
- RepoConfig: git detection

Additional bugs found and filed:
- laravel#55: DatabaseRestoreCreate completely broken (TypeError)
- laravel#56: DatabaseSnapshotCreate missing CLI options
- laravel#57: DatabaseClusterUpdate unusable non-interactively

352 tests, 381 assertions, 0 failures.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…nded tests

Brings total to 87 test files, 378 tests, 409 assertions — covering
all 87 commands (~100% command coverage).

New tests:
- ShipTest (6 tests) — full non-interactive workflow, custom flags, error cases
- BrowserTest (3 tests) — URL resolution, Process mock
- DashboardTest (2 tests) — URL resolution, Process mock
- CompletionsTest (4 tests) — bash/zsh/fish completion scripts
- DeployMonitorTest expanded (3+1 skipped) — no-app detection
- EnvironmentLogsTest expanded (7 tests) — time filters, JSON output
- DomainUpdateTest expanded (4 tests) — verification methods, JSON, name lookup

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.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.

1 participant