Skip to content

Commit 4e537c9

Browse files
committed
fix(#138): add tests for Get-NovaModuleSelfUpdatePlanContext behavior
- verify empty lookup fields when no result is available - ensure fallback to SourceRepository when candidate omits Repository
1 parent 1e47832 commit 4e537c9

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

tests/UpdateNotification.Tests.ps1

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,39 @@ Describe 'Update notification behavior' {
275275
}
276276
}
277277

278+
It 'Get-NovaModuleSelfUpdatePlanContext returns empty lookup fields when no lookup result is available' {
279+
InModuleScope $script:moduleName {
280+
$result = Get-NovaModuleSelfUpdatePlanContext -LookupResult $null -PrereleaseNotificationsEnabled:$true
281+
282+
$result.LookupCandidateVersion | Should -BeNullOrEmpty
283+
$result.LookupCandidateChannel | Should -BeNullOrEmpty
284+
$result.LookupRepository | Should -BeNullOrEmpty
285+
$result.PrereleaseNotificationsEnabled | Should -BeTrue
286+
}
287+
}
288+
289+
It 'Get-NovaModuleSelfUpdatePlanContext falls back to SourceRepository when the selected lookup candidate omits Repository' {
290+
InModuleScope $script:moduleName {
291+
$lookupResult = [pscustomobject]@{
292+
SourceRepository = 'PSGallery'
293+
Stable = [pscustomobject]@{
294+
Version = '1.9.1'
295+
Channel = 'Stable'
296+
}
297+
Prerelease = [pscustomobject]@{
298+
Version = '2.0.0-beta'
299+
Channel = 'Prerelease'
300+
}
301+
}
302+
303+
$result = Get-NovaModuleSelfUpdatePlanContext -LookupResult $lookupResult -PrereleaseNotificationsEnabled:$true
304+
305+
$result.LookupCandidateVersion | Should -Be '2.0.0-beta'
306+
$result.LookupCandidateChannel | Should -Be 'Prerelease'
307+
$result.LookupRepository | Should -Be 'PSGallery'
308+
}
309+
}
310+
278311
It 'Get-NovaModuleSelfUpdateWorkflowContext throws when update lookup cannot resolve a candidate' {
279312
InModuleScope $script:moduleName {
280313
Mock Read-NovaUpdateNotificationPreference {[pscustomobject]@{PrereleaseNotificationsEnabled = $true}}

0 commit comments

Comments
 (0)