-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGetNovaUpdateNotificationPreferenceStatus.Tests.ps1
More file actions
40 lines (33 loc) · 2.15 KB
/
Copy pathGetNovaUpdateNotificationPreferenceStatus.Tests.ps1
File metadata and controls
40 lines (33 loc) · 2.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
BeforeAll {
$projectRoot = Split-Path -Parent (Split-Path -Parent (Split-Path -Parent $PSScriptRoot))
. (Join-Path $projectRoot 'src/private/update/GetNovaUpdateNotificationPreferenceStatus.ps1')
function Read-NovaUpdateNotificationPreference {return [pscustomobject]@{PrereleaseNotificationsEnabled = $true}}
function Get-NovaUpdateSettingsFilePath {return '/tmp/nova-settings.json'}
}
Describe 'Get-NovaUpdateNotificationPreferenceStatus' {
It 'returns the stored preference along with the settings file path' {
Mock Read-NovaUpdateNotificationPreference {return [pscustomobject]@{PrereleaseNotificationsEnabled = $false}}
Mock Get-NovaUpdateSettingsFilePath {return '/some/path/settings.json'}
Mock Test-Path {return $true}
Mock Write-Verbose {}
$status = Get-NovaUpdateNotificationPreferenceStatus
$status.PrereleaseNotificationsEnabled | Should -BeFalse
$status.StableReleaseNotificationsEnabled | Should -BeTrue
$status.SettingsPath | Should -Be '/some/path/settings.json'
Assert-MockCalled Write-Verbose -Times 1 -ParameterFilter {
$Message -eq 'Prerelease self-updates are disabled. Stable self-updates remain available. Settings file: /some/path/settings.json'
}
}
It 'explains when the default preference is being used because the settings file is missing' {
Mock Read-NovaUpdateNotificationPreference {return [pscustomobject]@{PrereleaseNotificationsEnabled = $true}}
Mock Get-NovaUpdateSettingsFilePath {return '/some/path/settings.json'}
Mock Test-Path {return $false}
Mock Write-Verbose {}
$status = Get-NovaUpdateNotificationPreferenceStatus
$status.PrereleaseNotificationsEnabled | Should -BeTrue
$status.SettingsPath | Should -Be '/some/path/settings.json'
Assert-MockCalled Write-Verbose -Times 1 -ParameterFilter {
$Message -eq 'No settings file was found at /some/path/settings.json. Using the default setting: prerelease self-updates are enabled. Stable self-updates remain available. Use Set-NovaUpdateNotificationPreference to store a different preference.'
}
}
}