Skip to content

Commit 113115c

Browse files
committed
Implement major version check (#28)
* implement major version check * add test
1 parent 894e95a commit 113115c

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

app/Jobs/UpdateSite.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,16 @@ public function handle(): void
5353
return;
5454
}
5555

56+
// Do not make a major version update
57+
$majorVersionCms = (int) $healthResult->cms_version;
58+
$majorTargetVersion = (int) $this->targetVersion;
59+
60+
if ($majorVersionCms <> $majorTargetVersion) {
61+
Log::info("No major update for Site: " . $this->site->id);
62+
63+
return;
64+
}
65+
5666
// Store pre-update response code
5767
$this->preUpdateCode = $this->site->getFrontendStatus();
5868

tests/Unit/Jobs/UpdateSiteTest.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,28 @@ public function testJobQuitsIfWeDetectALoopForAVersion()
7676
$this->assertTrue(true);
7777
}
7878

79+
public function testJobQuitsIfAvailableUpdateWouldBeAMajorUpdate()
80+
{
81+
$site = $this->getSiteMock(
82+
[
83+
'checkHealth' => $this->getHealthCheckMock(),
84+
'getUpdate' => $this->getGetUpdateMock("2.0.0")
85+
]
86+
);
87+
88+
Log::spy();
89+
90+
$object = new UpdateSite($site, "2.0.0");
91+
$object->handle();
92+
93+
Log::shouldHaveReceived('info')
94+
->once()
95+
->withArgs(function ($message) {
96+
return str_contains($message, 'No major update for Site');
97+
});
98+
99+
$this->assertTrue(true);
100+
}
79101
public function testJobQuitsIfAvailableUpdateDoesNotMatchTargetVersion()
80102
{
81103
$site = $this->getSiteMock(

0 commit comments

Comments
 (0)