Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update task Generate_Markdown_For_DSC_Resources to use old config key #162

Merged
merged 2 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading