Skip to content

Commit 9731598

Browse files
authored
Implement major version check (#28)
* implement major version check #27 * add test
1 parent f1692e0 commit 9731598

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

app/Jobs/UpdateSite.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,16 @@ public function handle(): void
4444
return;
4545
}
4646

47+
// Do not make a major version update
48+
$majorVersionCms = (int) $healthResult->cms_version;
49+
$majorTargetVersion = (int) $this->targetVersion;
50+
51+
if ($majorVersionCms <> $majorTargetVersion) {
52+
Log::info("No major update for Site: " . $this->site->id);
53+
54+
return;
55+
}
56+
4757
// Store pre-update response code
4858
$this->preUpdateCode = $this->site->getFrontendStatus();
4959

tests/Unit/Jobs/UpdateSiteTest.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,29 @@ public function testJobQuitsIfNoUpdateIsAvailable()
5858
$this->assertTrue(true);
5959
}
6060

61+
public function testJobQuitsIfAvailableUpdateWouldBeAMajorUpdate()
62+
{
63+
$site = $this->getSiteMock(
64+
[
65+
'checkHealth' => $this->getHealthCheckMock(),
66+
'getUpdate' => $this->getGetUpdateMock("2.0.0")
67+
]
68+
);
69+
70+
Log::spy();
71+
72+
$object = new UpdateSite($site, "2.0.0");
73+
$object->handle();
74+
75+
Log::shouldHaveReceived('info')
76+
->once()
77+
->withArgs(function ($message) {
78+
return str_contains($message, 'No major update for Site');
79+
});
80+
81+
$this->assertTrue(true);
82+
}
83+
6184
public function testJobQuitsIfAvailableUpdateDoesNotMatchTargetVersion()
6285
{
6386
$site = $this->getSiteMock(

0 commit comments

Comments
 (0)