Skip to content

Commit 8422ae7

Browse files
committed
fix: close remaining new-code coverage gaps
1 parent 8dca978 commit 8422ae7

4 files changed

Lines changed: 84 additions & 0 deletions

File tree

tests/private/cli/ConfirmNovaCliAction.Tests.ps1

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,14 @@ Describe 'Invoke-NovaCliNativeConsoleReadKey' {
4343
$result = Invoke-NovaCliNativeConsoleReadKey -Reader $reader
4444
$result.KeyChar | Should -Be 'Q'
4545
}
46+
It 'uses the default reader when one is not provided' {
47+
Mock Get-NovaCliNativeConsoleReadKeyReader { { [pscustomobject]@{KeyChar = [char]'R'} } }
48+
49+
$result = Invoke-NovaCliNativeConsoleReadKey
50+
51+
$result.KeyChar | Should -Be 'R'
52+
Assert-MockCalled Get-NovaCliNativeConsoleReadKeyReader -Times 1 -Exactly
53+
}
4654
}
4755

4856
Describe 'Invoke-NovaCliConsoleReadKey' {

tests/private/quality/InvokeNovaTestWorkflow.Tests.ps1

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,37 @@ Describe 'Invoke-NovaTestWorkflow' {
9090
$workflowContext.PesterConfig.TestResult.OutputPath | Should -Be '/tmp/nova-project/artifacts/TestResults.xml'
9191
}
9292

93+
It 'falls back to CodeCoverage as the target object when the workflow context has no test result path' {
94+
$workflowContext = [pscustomobject]@{
95+
ProjectInfo = [pscustomobject]@{
96+
Pester = [ordered]@{CodeCoverage = [ordered]@{Enabled = $true; CoveragePercentTarget = 90}}
97+
}
98+
}
99+
100+
$assertion = Get-NovaCoverageTargetAssertionScriptBlock -WorkflowContext $workflowContext
101+
102+
$thrown = $null
103+
try {
104+
& $assertion -WorkflowContext $workflowContext -TestResult ([pscustomobject]@{Result = 'Passed'})
105+
} catch {
106+
$thrown = $_
107+
}
108+
109+
$thrown | Should -Not -BeNullOrEmpty
110+
$thrown.FullyQualifiedErrorId | Should -Be 'Nova.Workflow.CodeCoveragePercentMissing'
111+
$thrown.TargetObject | Should -Be 'CodeCoverage'
112+
}
113+
114+
It 'treats a blank configured coverage target as not configured' {
115+
$workflowContext = [pscustomobject]@{
116+
ProjectInfo = [pscustomobject]@{
117+
Pester = [ordered]@{CodeCoverage = [ordered]@{Enabled = $true; CoveragePercentTarget = ''}}
118+
}
119+
}
120+
121+
Get-NovaConfiguredCoveragePercentTarget -WorkflowContext $workflowContext | Should -BeNullOrEmpty
122+
}
123+
93124
It 'suppresses global progress output around the Pester run and restores the previous preference' {
94125
$workflowContext = [pscustomobject]@{
95126
ProjectInfo = [pscustomobject]@{Pester = [ordered]@{}}

tests/private/quality/duplicates/AssertBuiltModuleHasNoDuplicateFunctionNames.Tests.ps1

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,21 @@ function Get-Alpha {
7070
$_.Exception.Message | Should -Match 'src/private/GetAlphaOverride\.ps1'
7171
}
7272
}
73+
74+
It 'throws a parse-specific error when the built module cannot be parsed' {
75+
$projectInfo = New-DuplicateValidationProjectInfo -ProjectRoot $script:projectRoot -ModuleContent @'
76+
function Get-Alpha {
77+
'@ -SourceFileMap @{
78+
'src/public/GetAlpha.ps1' = 'function Get-Alpha {}'
79+
}
80+
81+
try {
82+
Assert-BuiltModuleHasNoDuplicateFunctionName -ProjectInfo $projectInfo
83+
throw 'Expected parse validation to fail.'
84+
} catch {
85+
$_.FullyQualifiedErrorId | Should -Be 'Nova.Configuration.BuiltModuleDuplicateValidationParseFailed'
86+
$_.Exception.Message | Should -Match 'contains parse errors'
87+
$_.Exception.Message | Should -Match 'NovaModuleTools\.psm1'
88+
}
89+
}
7390
}

tests/private/update/InvokeNovaModuleUpdateNotification.Tests.ps1

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,32 @@ Describe 'Invoke-NovaModuleUpdateNotification' {
5050
{Invoke-NovaModuleUpdateNotification} | Should -Not -Throw
5151
Assert-MockCalled Write-NovaAvailableModuleUpdateWarning -Times 0
5252
}
53+
54+
It 'warns about a newer prerelease when prerelease notifications are enabled and a prerelease update is available' {
55+
Mock Read-NovaUpdateNotificationPreference {[pscustomobject]@{PrereleaseNotificationsEnabled = $true}}
56+
Mock Get-NovaInstalledModuleVersionInfo {
57+
[pscustomobject]@{
58+
ModuleName = 'NovaModuleTools'
59+
Version = '1.0.0'
60+
SemanticVersion = [semver]'1.0.0'
61+
IsPrerelease = $false
62+
}
63+
}
64+
Mock Invoke-NovaModuleUpdateLookup {
65+
[pscustomobject]@{
66+
Stable = [pscustomobject]@{Version = '1.1.0'}
67+
Prerelease = [pscustomobject]@{Version = '1.2.0-preview'}
68+
}
69+
}
70+
Mock Get-NovaAvailableSemanticVersion {[semver]'1.1.0'}
71+
Mock Test-NovaStableUpdateAvailable {$false}
72+
Mock Test-NovaPrereleaseUpdateAvailable {$true}
73+
Mock Write-NovaAvailableModuleUpdateWarning {}
74+
75+
Invoke-NovaModuleUpdateNotification
76+
77+
Assert-MockCalled Write-NovaAvailableModuleUpdateWarning -Times 1 -Exactly -ParameterFilter {
78+
$CurrentVersion -eq '1.0.0' -and $AvailableVersion -eq '1.2.0-preview' -and $Prerelease
79+
}
80+
}
5381
}

0 commit comments

Comments
 (0)