Skip to content

Commit cf48b82

Browse files
authored
Fix QA test for ChangelogManagement v3.0.1 (#405)
- Now the QA test that verifies that the Unreleased section header is present in the CHANGELOG.md correctly supports ChangelogManagement v3.0.1. - The QA tests can now be debugged by `Invoke-Pester` directly, before it had to be started by the build script `build.ps1`. This will also help the Pester Tests VS Code extension to be able to run the tests.
1 parent 50b215e commit cf48b82

File tree

3 files changed

+58
-6
lines changed

3 files changed

+58
-6
lines changed

CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1414
- `Get-MofSchemaName`
1515
- Permanently skipped a test that the build worker `ubuntu-latest` were
1616
unable to run due to missing shared library 'libmi'.
17+
- Now the QA test that verifies that the Unreleased section header is present
18+
in the CHANGELOG.md correctly supports ChangelogManagement v3.0.1.
1719
- Task `Convert_Pester_Coverage`
1820
- No longer throws an exception when there was just one missed command
1921
for a test suite. Fixes [#407](https://github.com/gaelcolas/Sampler/issues/407).
@@ -23,6 +25,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2325
- Task `Build_ModuleOutput_ModuleBuilder`
2426
- Proper support for DSC composite resources (*.schema.psm1).
2527

28+
### Changed
29+
30+
- The QA tests can now be debugged by `Invoke-Pester` directly, before it
31+
had to be started by the build script `build.ps1`. This will also help
32+
the Pester Tests VS Code extension to be able to run the tests.
33+
2634
## [0.116.0] - 2022-11-08
2735

2836
### Removed

Sampler/Templates/Sampler/module.tests.ps1.template

+25-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
11
BeforeDiscovery {
2+
$projectPath = "$($PSScriptRoot)\..\.." | Convert-Path
3+
4+
<#
5+
If the QA tests are run outside of the build script (e.g with Invoke-Pester)
6+
the parent scope has not set the variable $ProjectName.
7+
#>
8+
if (-not $ProjectName)
9+
{
10+
# Assuming project folder name is project name.
11+
$ProjectName = Get-SamplerProjectName -BuildRoot $projectPath
12+
}
13+
214
$script:moduleName = $ProjectName
315

416
Remove-Module -Name $script:moduleName -Force -ErrorAction SilentlyContinue
@@ -9,11 +21,21 @@ BeforeDiscovery {
921
}
1022

1123
BeforeAll {
12-
$script:moduleName = $ProjectName
13-
1424
# Convert-Path required for PS7 or Join-Path fails
1525
$projectPath = "$($PSScriptRoot)\..\.." | Convert-Path
1626

27+
<#
28+
If the QA tests are run outside of the build script (e.g with Invoke-Pester)
29+
the parent scope has not set the variable $ProjectName.
30+
#>
31+
if (-not $ProjectName)
32+
{
33+
# Assuming project folder name is project name.
34+
$ProjectName = Get-SamplerProjectName -BuildRoot $projectPath
35+
}
36+
37+
$script:moduleName = $ProjectName
38+
1739
$sourcePath = (
1840
Get-ChildItem -Path $projectPath\*\*.psd1 |
1941
Where-Object -FilterScript {
@@ -57,7 +79,7 @@ Describe 'Changelog Management' -Tag 'Changelog' {
5779
}
5880

5981
It 'Changelog should have an Unreleased header' -Skip:$skipTest {
60-
(Get-ChangelogData -Path (Join-Path -Path $ProjectPath -ChildPath 'CHANGELOG.md') -ErrorAction Stop).Unreleased.RawData | Should -Not -BeNullOrEmpty
82+
(Get-ChangelogData -Path (Join-Path -Path $ProjectPath -ChildPath 'CHANGELOG.md') -ErrorAction Stop).Unreleased | Should -Not -BeNullOrEmpty
6183
}
6284
}
6385

tests/QA/module.tests.ps1

+25-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
11
BeforeDiscovery {
2+
$projectPath = "$($PSScriptRoot)\..\.." | Convert-Path
3+
4+
<#
5+
If the QA tests are run outside of the build script (e.g with Invoke-Pester)
6+
the parent scope has not set the variable $ProjectName.
7+
#>
8+
if (-not $ProjectName)
9+
{
10+
# Assuming project folder name is project name.
11+
$ProjectName = Get-SamplerProjectName -BuildRoot $projectPath
12+
}
13+
214
$script:moduleName = $ProjectName
315

416
Remove-Module -Name $script:moduleName -Force -ErrorAction SilentlyContinue
@@ -9,11 +21,21 @@ BeforeDiscovery {
921
}
1022

1123
BeforeAll {
12-
$script:moduleName = $ProjectName
13-
1424
# Convert-Path required for PS7 or Join-Path fails
1525
$projectPath = "$($PSScriptRoot)\..\.." | Convert-Path
1626

27+
<#
28+
If the QA tests are run outside of the build script (e.g with Invoke-Pester)
29+
the parent scope has not set the variable $ProjectName.
30+
#>
31+
if (-not $ProjectName)
32+
{
33+
# Assuming project folder name is project name.
34+
$ProjectName = Get-SamplerProjectName -BuildRoot $projectPath
35+
}
36+
37+
$script:moduleName = $ProjectName
38+
1739
$sourcePath = (
1840
Get-ChildItem -Path $projectPath\*\*.psd1 |
1941
Where-Object -FilterScript {
@@ -57,7 +79,7 @@ Describe 'Changelog Management' -Tag 'Changelog' {
5779
}
5880

5981
It 'Changelog should have an Unreleased header' -Skip:$skipTest {
60-
(Get-ChangelogData -Path (Join-Path -Path $ProjectPath -ChildPath 'CHANGELOG.md') -ErrorAction Stop).Unreleased.RawData | Should -Not -BeNullOrEmpty
82+
(Get-ChangelogData -Path (Join-Path -Path $ProjectPath -ChildPath 'CHANGELOG.md') -ErrorAction Stop).Unreleased | Should -Not -BeNullOrEmpty
6183
}
6284
}
6385

0 commit comments

Comments
 (0)