Skip to content

Commit c140f1d

Browse files
committed
Return null when no update is available
1 parent edb3ea3 commit c140f1d

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

CRX/CRX.psd1

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
@{
33
RootModule = 'CRX.psm1'
4-
ModuleVersion = '0.2.0'
4+
ModuleVersion = '0.2.1'
55
GUID = 'b5433b6c-b423-4049-8c5e-b3a50566fcf2'
66
Author = 'Alan Plocieniak'
77
CompanyName = 'Alan Plocieniak'

CRX/Public/Get-CRXUpdateInfo.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ function Get-CRXUpdateInfo {
99
try {
1010
$update = Invoke-RestMethod -Uri $url
1111
$app = $update.gupdate.app
12-
if ($app -and $app.updatecheck) {
12+
if ($app -and $app.updatecheck -and $app.updatecheck.status -ne 'noupdate') {
1313
return [CRXUpdateInfo]::new($app.updatecheck)
1414
}
1515
}

tests/CRX.Tests.ps1

+19-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ if (-not (Get-Module -Name Pester)) {
44
Import-Module .\CRX\CRX.psm1 -Force
55

66
Describe 'CRX.Tests' {
7-
BeforeAll{
7+
BeforeAll {
88
$testUrl = 'https://localhost.com/crx/blobs/ASuc5ohLVu-itAJfZqe6NgPkB0pCREbOH49PhxJq4pMdp7MWQx-ycGQt8dsD8WUSM_dTlB5sLwXljaUve7GTKh485NrRlNGdmT7O5aT9uS4R9jmIqNJBAMZSmuV9IZ0e0VV7jGd-rrI-YR5eoIra2Q/AOCLHCCCFDKJDDGPAAAJLDGLJHLLHGMD_4_0_0_0.crx'
99
$testExtensionId = 'aoclhcccfdkjddgpaaajldgljhllhgmd'
1010
}
@@ -20,6 +20,24 @@ Describe 'CRX.Tests' {
2020
$response = Get-CRXUpdateInfo "invalid"
2121
$response | Should -BeNullOrEmpty
2222
}
23+
24+
It 'Should return null when no update is available' {
25+
Mock -CommandName Invoke-RestMethod -ModuleName CRX -MockWith {
26+
param ($Uri, $OutFile)
27+
return @{
28+
gupdate = @{
29+
app = @{
30+
updatecheck = @{
31+
status = 'noupdate'
32+
}
33+
}
34+
}
35+
}
36+
}
37+
38+
$result = Get-CRXUpdateInfo -Id $testExtensionId
39+
$result | Should -Be $null
40+
}
2341
}
2442

2543
Context 'Test-CRXUpdateAvailable' {

0 commit comments

Comments
 (0)