Skip to content

Commit 16beb7e

Browse files
authored
Feature/adjust requirment notification behavior (#32)
* adjust fail notifications * fix tests
1 parent 50b8840 commit 16beb7e

File tree

4 files changed

+10
-21
lines changed

4 files changed

+10
-21
lines changed

app/Console/Commands/PerformUpdate.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,6 @@ public function handle(): int
3535
/** @var Site $site */
3636
$site = Site::findOrFail($this->input->getArgument('siteId'));
3737

38-
if (!$site->update_requirement_state) {
39-
$this->output->writeln('Update requirements not met, aborting!');
40-
41-
return Command::FAILURE;
42-
}
43-
4438
UpdateSite::dispatchSync(
4539
$site,
4640
$targetVersion

app/Console/Commands/QueueUpdates.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ public function handle(): int
3939
$this->output->writeln('Pushing update jobs');
4040

4141
$sites = Site::query()
42-
->where('update_requirement_state', '=', true)
4342
->where(
4443
'cms_version',
4544
'like',

app/Jobs/UpdateSite.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,6 @@ public function handle(): void
5151
return;
5252
}
5353

54-
if (!$healthResult->update_requirement_state) {
55-
Log::info("Site does not meet requirements, abort");
56-
57-
return;
58-
}
59-
6054
// Do not make a major version update
6155
$majorVersionCms = (int) $healthResult->cms_version;
6256
$majorTargetVersion = (int) $this->targetVersion;
@@ -67,6 +61,14 @@ public function handle(): void
6761
return;
6862
}
6963

64+
// Update is available, but let's check if the requirements are met
65+
if (!$healthResult->update_requirement_state) {
66+
throw new UpdateException(
67+
'verify',
68+
"Site does not meet requirements"
69+
);
70+
}
71+
7072
// Store pre-update response code
7173
$this->preUpdateCode = $this->site->getFrontendStatus();
7274

tests/Unit/Jobs/UpdateSiteTest.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,23 +61,17 @@ public function testJobQuitsIfNoUpdateIsAvailable()
6161

6262
public function testJobQuitsIfRequirementsArentMet()
6363
{
64+
$this->expectExceptionMessage("Site does not meet requirements");
65+
6466
$site = $this->getSiteMock(
6567
[
6668
'checkHealth' => $this->getHealthCheckMock(['update_requirement_state' => false])
6769
]
6870
);
6971

70-
Log::spy();
71-
7272
$object = new UpdateSite($site, "1.0.1");
7373
$object->handle();
7474

75-
Log::shouldHaveReceived('info')
76-
->once()
77-
->withArgs(function ($message) {
78-
return str_contains($message, 'Site does not meet requirements, abort');
79-
});
80-
8175
$this->assertTrue(true);
8276
}
8377

0 commit comments

Comments
 (0)