Skip to content

Commit 2687b69

Browse files
Merge branch 'main' into maintenance/lock-pester-major-6
2 parents 4b2b7bc + ab2632b commit 2687b69

7 files changed

Lines changed: 91 additions & 1 deletion

File tree

.github/workflows/Process-PSModule.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ permissions:
2727

2828
jobs:
2929
Process-PSModule:
30-
uses: PSModule/Process-PSModule/.github/workflows/workflow.yml@60bdf8a5a4c92c53fcf2a8d23f7d5f5c93e6864e # v5.4.3
30+
uses: PSModule/Process-PSModule/.github/workflows/workflow.yml@d4020f3c9c3621cebae5d8bf4ffaf10f55c1784a # v6.1.2
3131
secrets:
3232
APIKEY: ${{ secrets.APIKEY }}
33+
TestData: >-
34+
{ "secrets": { "TEST_SECRET": "${{ secrets.TEST_SECRET }}" },
35+
"variables": { "TEST_VARIABLE": ${{ toJSON(vars.TEST_VARIABLE) }} } }
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
function Get-IndexSectionTest {
2+
<#
3+
.SYNOPSIS
4+
Performs tests on a module.
5+
6+
.DESCRIPTION
7+
Performs tests on a module.
8+
9+
.EXAMPLE
10+
Get-IndexSectionTest -Name 'World'
11+
12+
"Hello, World!"
13+
#>
14+
[CmdletBinding()]
15+
param (
16+
# Name of the person to greet.
17+
[Parameter(Mandatory)]
18+
[string] $Name
19+
)
20+
Write-Output "Hello, $Name!"
21+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Index Section
2+
3+
This section's landing page is provided by an `index.md` file.
4+
5+
When Process-PSModule builds the documentation site, this page becomes the landing page for the **Index Section** group in the navigation on GitHub Pages.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
function Get-NamedSectionTest {
2+
<#
3+
.SYNOPSIS
4+
Performs tests on a module.
5+
6+
.DESCRIPTION
7+
Performs tests on a module.
8+
9+
.EXAMPLE
10+
Get-NamedSectionTest -Name 'World'
11+
12+
"Hello, World!"
13+
#>
14+
[CmdletBinding()]
15+
param (
16+
# Name of the person to greet.
17+
[Parameter(Mandatory)]
18+
[string] $Name
19+
)
20+
Write-Output "Hello, $Name!"
21+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Named Section
2+
3+
This section's landing page is provided by a file named after its folder (`NamedSection.md`).
4+
5+
When Process-PSModule builds the documentation site, this page becomes the landing page for the **Named Section** group in the navigation on GitHub Pages.

tests/Environment.Tests.ps1

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
[Diagnostics.CodeAnalysis.SuppressMessageAttribute(
2+
'PSReviewUnusedParameter', '',
3+
Justification = 'Required for Pester tests'
4+
)]
5+
[Diagnostics.CodeAnalysis.SuppressMessageAttribute(
6+
'PSUseDeclaredVarsMoreThanAssignments', '',
7+
Justification = 'Required for Pester tests'
8+
)]
9+
[CmdletBinding()]
10+
param()
11+
12+
Describe 'TestData is exposed to the module tests' {
13+
# Showcase for the Process-PSModule 'TestData' feature. The calling workflow
14+
# (.github/workflows/Process-PSModule.yml) passes a repository secret and a repository
15+
# variable through a single TestData object, and the framework exposes each of them to
16+
# the module tests as an environment variable. To see these run, add a repository secret
17+
# named 'TEST_SECRET' and a repository variable named 'TEST_VARIABLE'. When they are not
18+
# configured the tests skip, so a fresh repository created from this template stays green.
19+
20+
It 'Exposes the secret from the "secrets" map as $env:TEST_SECRET' -Skip:([string]::IsNullOrEmpty($env:TEST_SECRET)) {
21+
# Values in the "secrets" map are masked in the workflow logs.
22+
$env:TEST_SECRET | Should -Not -BeNullOrEmpty
23+
}
24+
25+
It 'Exposes the variable from the "variables" map as $env:TEST_VARIABLE' -Skip:([string]::IsNullOrEmpty($env:TEST_VARIABLE)) {
26+
# Values in the "variables" map are not masked.
27+
$env:TEST_VARIABLE | Should -Not -BeNullOrEmpty
28+
}
29+
}

tests/PSModuleTest.Tests.ps1

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,10 @@ Describe 'Module' {
2424
It 'Function: Test-PSModuleTest' {
2525
Test-PSModuleTest -Name 'World' | Should -Be 'Hello, World!'
2626
}
27+
It 'Function: Get-IndexSectionTest' {
28+
Get-IndexSectionTest -Name 'World' | Should -Be 'Hello, World!'
29+
}
30+
It 'Function: Get-NamedSectionTest' {
31+
Get-NamedSectionTest -Name 'World' | Should -Be 'Hello, World!'
32+
}
2733
}

0 commit comments

Comments
 (0)