Skip to content

Commit 19aa9a6

Browse files
committed
#215 feat: add tests for NovaPackage and NovaTest workflows, enhancing coverage and status messaging
1 parent 4c1b863 commit 19aa9a6

5 files changed

Lines changed: 100 additions & 0 deletions

tests/private/package/InvokeNovaPackageWorkflow.Tests.ps1

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,26 @@ Describe 'Invoke-NovaPackageWorkflow' {
6565
$result | Should -BeNullOrEmpty
6666
}
6767
}
68+
69+
Describe 'Get-NovaPackageWorkflowStatusMessage' {
70+
It 'reports the created artifact count when more than one artifact was produced' {
71+
$workflowContext = [pscustomobject]@{
72+
ProjectInfo = [pscustomobject]@{
73+
ProjectName = 'Demo'
74+
}
75+
}
76+
77+
Get-NovaPackageWorkflowStatusMessage -WorkflowContext $workflowContext -ArtifactCount 2 | Should -Be 'Created 2 package artifacts for Demo'
78+
}
79+
}
80+
81+
Describe 'Get-NovaPackageWorkflowResultTarget' {
82+
It 'falls back to the workflow target when artifacts do not expose output directories' {
83+
$workflowContext = [pscustomobject]@{
84+
Target = '/p/Demo.1.0.0.nupkg'
85+
}
86+
87+
$artifacts = @([pscustomobject]@{PackagePath = '/p/Demo.1.0.0.nupkg'; OutputDirectory = $null})
88+
Get-NovaPackageWorkflowResultTarget -WorkflowContext $workflowContext -Artifacts $artifacts | Should -Be '/p/Demo.1.0.0.nupkg'
89+
}
90+
}

tests/private/quality/InvokeNovaTestWorkflow.Tests.ps1

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,3 +322,26 @@ Describe 'Invoke-NovaTestWorkflow' {
322322
}
323323

324324
}
325+
326+
Describe 'Get-NovaTestWorkflowCoverageMessage' {
327+
It 'includes the measured and configured coverage values when both are available' {
328+
$workflowContext = [pscustomobject]@{
329+
ProjectInfo = [pscustomobject]@{
330+
Pester = [ordered]@{
331+
CodeCoverage = [ordered]@{
332+
Enabled = $true
333+
CoveragePercentTarget = 90
334+
}
335+
}
336+
}
337+
}
338+
339+
$testResult = [pscustomobject]@{
340+
CodeCoverage = [pscustomobject]@{
341+
CoveragePercent = 66.67
342+
}
343+
}
344+
345+
Get-NovaTestWorkflowCoverageMessage -WorkflowContext $workflowContext -TestResult $testResult | Should -Be 'Measured code coverage: 66.67% (target: 90%)'
346+
}
347+
}

tests/private/release/InvokeNovaReleaseWorkflow.Tests.ps1

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,34 @@ Describe 'Get-NovaReleaseBuildWorkflowParameterMap' {
2323
}
2424
}
2525

26+
Describe 'Get-NovaReleaseWorkflowResultVersion' {
27+
It 'returns null when no version result is available' {
28+
Get-NovaReleaseWorkflowResultVersion -VersionResult $null | Should -BeNullOrEmpty
29+
}
30+
31+
It 'prefers NewVersion when the version result exposes it' {
32+
Get-NovaReleaseWorkflowResultVersion -VersionResult ([pscustomobject]@{NewVersion = '1.2.3'; Version = '1.2.2'}) | Should -Be '1.2.3'
33+
}
34+
35+
It 'falls back to Version when NewVersion is not present' {
36+
Get-NovaReleaseWorkflowResultVersion -VersionResult ([pscustomobject]@{Version = '1.2.3'}) | Should -Be '1.2.3'
37+
}
38+
39+
It 'returns null when the version result has no version-like properties' {
40+
Get-NovaReleaseWorkflowResultVersion -VersionResult ([pscustomobject]@{Other = 'x'}) | Should -BeNullOrEmpty
41+
}
42+
}
43+
44+
Describe 'Get-NovaReleaseWorkflowStatusMessage' {
45+
It 'returns a plan-ready message without a version in WhatIf mode' {
46+
Get-NovaReleaseWorkflowStatusMessage -ProjectInfo ([pscustomobject]@{ProjectName = 'NovaModuleTools'}) -WhatIfEnabled | Should -Be 'Release plan ready for NovaModuleTools'
47+
}
48+
49+
It 'returns a released message without a version when no version was resolved' {
50+
Get-NovaReleaseWorkflowStatusMessage -ProjectInfo ([pscustomobject]@{ProjectName = 'NovaModuleTools'}) | Should -Be 'Released Nova module: NovaModuleTools'
51+
}
52+
}
53+
2654
Describe 'Test-NovaReleaseWorkflowShouldRestoreBuiltModule' {
2755
It 'returns true when CI is on and WhatIf is not set' {
2856
Test-NovaReleaseWorkflowShouldRestoreBuiltModule -WorkflowParams @{} -ContinuousIntegrationRequested | Should -BeTrue

tests/private/update/InvokeNovaModuleSelfUpdateWorkflow.Tests.ps1

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,25 @@ Describe 'Invoke-NovaModuleSelfUpdateOrStop' {
4343
}
4444
}
4545

46+
Describe 'Get-NovaModuleSelfUpdateWorkflowUpdateStatus' {
47+
It 'describes prerelease installs explicitly' {
48+
$workflowContext = [pscustomobject]@{
49+
Plan = [pscustomobject]@{
50+
IsPrereleaseTarget = $true
51+
TargetVersion = '1.2.0-preview1'
52+
}
53+
}
54+
55+
Get-NovaModuleSelfUpdateWorkflowUpdateStatus -WorkflowContext $workflowContext | Should -Be 'Installing prerelease version 1.2.0-preview1'
56+
}
57+
}
58+
59+
Describe 'Get-NovaModuleSelfUpdateWorkflowRepositoryLine' {
60+
It 'returns null when the repository name is blank' {
61+
Get-NovaModuleSelfUpdateWorkflowRepositoryLine -Result ([pscustomobject]@{LookupRepository = ''}) | Should -BeNullOrEmpty
62+
}
63+
}
64+
4665
Describe 'Invoke-NovaModuleSelfUpdateWorkflow' {
4766
BeforeEach {
4867
Mock Write-Message {}

tests/private/update/InvokeNovaUpdateNotificationPreferenceChange.Tests.ps1

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@ Describe 'Test-NovaUpdateNotificationPreferenceChangeWhatIfEnabled' {
1919
}
2020
}
2121

22+
Describe 'Get-NovaUpdateNotificationPreferenceChangeCommandLine' {
23+
It 'returns the disable command line when prerelease notifications are being turned off' {
24+
$workflowContext = [pscustomobject]@{PrereleaseNotificationsEnabled = $false}
25+
Get-NovaUpdateNotificationPreferenceChangeCommandLine -WorkflowContext $workflowContext | Should -Be 'Set-NovaUpdateNotificationPreference -DisablePrereleaseNotifications'
26+
}
27+
}
28+
2229
Describe 'Invoke-NovaUpdateNotificationPreferenceChange' {
2330
BeforeEach {
2431
Mock Write-Message {}

0 commit comments

Comments
 (0)