Skip to content

Commit

Permalink
Improve tests around service connection
Browse files Browse the repository at this point in the history
And fail a couple of edge-cases bugs discovered via new tests
  • Loading branch information
gmazzap committed May 27, 2024
1 parent c05057d commit 5c6b990
Show file tree
Hide file tree
Showing 2 changed files with 113 additions and 166 deletions.
12 changes: 8 additions & 4 deletions src/Package.php
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,10 @@ public function connect(Package $package): bool

// Don't connect, if already booted or boot failed
$failed = $this->statusIs(self::STATUS_FAILED);
if ($failed || $this->statusIs(self::STATUS_BOOTED)) {
$status = $failed ? 'errored' : 'booted';
$error = "{$errorMessage} to a {$status} package.";
if ($failed || $this->checkStatus(self::STATUS_INITIALIZED, '>=')) {
$reason = $failed ? 'an errored package' : 'a package with a built container';
$status = $failed ? 'failed' : 'built_container';
$error = "{$errorMessage} to {$reason}.";
do_action(
$this->hookName(self::ACTION_FAILED_CONNECTION),
$packageName,
Expand Down Expand Up @@ -315,7 +316,10 @@ static function () use ($package): Properties {

return true;
} catch (\Throwable $throwable) {
if (isset($packageName)) {
if (
isset($packageName)
&& (($this->connectedPackages[$packageName] ?? false) !== true)
) {
$this->connectedPackages[$packageName] = false;
}
$this->handleFailure($throwable, self::ACTION_FAILED_BUILD);
Expand Down
Loading

0 comments on commit 5c6b990

Please sign in to comment.