Skip to content

Commit

Permalink
Update task Generate_Markdown_For_DSC_Resources to use old config k…
Browse files Browse the repository at this point in the history
…ey (#162)
  • Loading branch information
johlju authored Oct 23, 2024
1 parent 66b21b9 commit 02e340b
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
header equals the filename.
- Task `Generate_Markdown_For_Public_Commands`
- Verbose output of the markdown files that was created.
- Task `Generate_Markdown_For_DSC_Resources`
- Outputs a warning message if the old configuration key is used in the
build configuration but keeps using the old configuration key.

### Fixed

Expand Down
11 changes: 10 additions & 1 deletion source/tasks/Generate_Markdown_For_DSC_Resources.build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,16 @@ Task Generate_Markdown_For_DSC_Resources {

Write-Build -Color 'Magenta' -Text 'Generating Wiki content for all DSC resources based on source and built module.'

$dscResourceMarkdownMetadata = $BuildInfo.'DscResource.DocGenerator'.Generate_Markdown_For_DSC_Resources
if ($BuildInfo.'DscResource.DocGenerator'.Generate_Wiki_Content)
{
Write-Warning -Message 'Build configuration is using the old configuration key ''Generate_Wiki_Content''. Update the build configuration to use the new configuration key ''Generate_Markdown_For_DSC_Resources'''

$dscResourceMarkdownMetadata = $BuildInfo.'DscResource.DocGenerator'.Generate_Wiki_Content
}
else
{
$dscResourceMarkdownMetadata = $BuildInfo.'DscResource.DocGenerator'.Generate_Markdown_For_DSC_Resources
}

New-DscResourceWikiPage -SourcePath $SourcePath -BuiltModulePath $builtModuleBase -OutputPath $wikiOutputPath -Metadata $dscResourceMarkdownMetadata -Force
}
38 changes: 37 additions & 1 deletion tests/unit/tasks/Generate_Markdown_For_DSC_Resources.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,43 @@ Describe 'Generate_Markdown_For_DSC_Resources' {
{
$taskParameters = @{
ProjectName = 'DscResource.DocGenerator'
SourcePath = $TestDrive
SourcePath = $TestDrive
}

Invoke-Build -Task $buildTaskName -File $script:buildScript.Definition @taskParameters
} | Should -Not -Throw

Assert-MockCalled -CommandName New-DscResourceWikiPage -Exactly -Times 1 -Scope It
}

It 'Should run the build task with old configuration key without throwing' {
{
$taskParameters = @{
ProjectName = 'DscResource.DocGenerator'
SourcePath = $TestDrive
BuildInfo = @{
'DscResource.DocGenerator' = @{
Generate_Wiki_Content = @{}
}
}
}

Invoke-Build -Task $buildTaskName -File $script:buildScript.Definition @taskParameters
} | Should -Not -Throw

Assert-MockCalled -CommandName New-DscResourceWikiPage -Exactly -Times 1 -Scope It
}

It 'Should run the build task with new configuration key without throwing' {
{
$taskParameters = @{
ProjectName = 'DscResource.DocGenerator'
SourcePath = $TestDrive
BuildInfo = @{
'DscResource.DocGenerator' = @{
Generate_Markdown_For_DSC_Resources = @{}
}
}
}

Invoke-Build -Task $buildTaskName -File $script:buildScript.Definition @taskParameters
Expand Down

0 comments on commit 02e340b

Please sign in to comment.