Check Stripe is configured on every path the sweep actually uses
The dry-run guard was copied from stripe:sync-catalogue, where it is right: that command's --dry-run touches nothing, because everything it compares already lives in our own tables. This command has no such local-only mode — the report IS a live activePricesFor() call, dry-run or not — so `! $dryRun &&` made the guard fire only on the one path that would have worked anyway. A --dry-run against an unconfigured account fell straight into HttpStripeClient's own exception instead of the clean error and self::FAILURE. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>feature/host-bootstrap
parent
277a6bab83
commit
571acd0013
|
|
@ -36,7 +36,13 @@ class SweepOrphanStripePrices extends Command
|
|||
$dryRun = (bool) $this->option('dry-run');
|
||||
$archive = (bool) $this->option('archive');
|
||||
|
||||
if (! $dryRun && ! $stripe->isConfigured()) {
|
||||
// Checked on EVERY path, unlike stripe:sync-catalogue's --dry-run,
|
||||
// which touches nothing because everything it compares is already in
|
||||
// our own tables. This command has no local-only mode: the report —
|
||||
// the whole point of it, dry-run or not — is activePricesFor(), a
|
||||
// live call. Skipping this check under --dry-run would not skip the
|
||||
// call, only the graceful error in front of it.
|
||||
if (! $stripe->isConfigured()) {
|
||||
$this->error('Stripe is not configured (STRIPE_SECRET is empty). Nothing was read.');
|
||||
|
||||
return self::FAILURE;
|
||||
|
|
|
|||
|
|
@ -64,3 +64,16 @@ it('touches nothing on a dry run, even when asked to archive', function () {
|
|||
|
||||
expect($this->stripe->archived)->toBe([]);
|
||||
});
|
||||
|
||||
it('fails cleanly on a dry run when Stripe is not configured, rather than throwing', function () {
|
||||
// Unlike stripe:sync-catalogue, this command has no local-only path: the
|
||||
// report itself is a live activePricesFor() call, dry-run or not. A guard
|
||||
// that only fired outside --dry-run would let this fall straight into
|
||||
// HttpStripeClient's own "not configured" exception instead of the clean
|
||||
// error below.
|
||||
$this->stripe->configured = false;
|
||||
|
||||
$this->artisan('stripe:sweep-orphan-prices', ['--dry-run' => true])
|
||||
->expectsOutputToContain('Stripe is not configured (STRIPE_SECRET is empty). Nothing was read.')
|
||||
->assertFailed();
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue