Skip to content

Commit fddcb50

Browse files
committed
Added Requires header to Tests
1 parent e8a3982 commit fddcb50

12 files changed

Lines changed: 41 additions & 9 deletions

‎Public/New-ModuleTemplate.ps1‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
The module loader is generated by New-ModuleLoader.
6565
#>
6666
function New-ModuleTemplate {
67-
[CmdletBinding(SupportsShouldProcess)]
67+
[CmdletBinding()]
6868
param(
6969
[Parameter(Mandatory)]
7070
[string]$Path,

‎Public/New-PesterTests.ps1‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,16 @@ function New-PesterTests {
4545

4646
# Template for the Pester test file
4747
$content = @'
48+
@ Requires -Module Pester
4849
Describe "__MODULE__ Module" {
4950
5051
BeforeAll {
51-
Import-Module "$PSScriptRoot/../__MODULE__.psd1" -Force
52+
$manifest = Join-Path $PSScriptRoot '..' '__MODULE__.psd1'
53+
Import-Module $manifest -Force
5254
}
5355
5456
It "Loads without error" {
55-
{ Import-Module "__MODULE__" -Force } | Should -Not -Throw
57+
{ Import-Module $manifest -Force } | Should -Not -Throw
5658
}
5759
5860
It "Exports at least one function" {

‎Tests/Initialize-GitRepository.Tests.ps1‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# Requires -Module Pester
12
Describe "Initialize-GitRepository" {
23

34
It "Initializes a git repository" {

‎Tests/New-AnalyzerSettings.Tests.ps1‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# Requires -Module Pester
12
Describe "New-AnalyzerSettings" {
23

34
It "Creates analyzer settings file" {

‎Tests/New-DocumentationScripts.Tests.ps1‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# Requires -Module Pester
12
Describe "New-DocumentationScripts" {
23

34
It "Creates documentation scripts" {

‎Tests/New-ModuleChangelog.Tests.ps1‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# Requires -Module Pester
12
Describe "New-ModuleChangelog" {
23

34
It "Creates a CHANGELOG.md file" {

‎Tests/New-ModuleFolders.Tests.ps1‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# Requires -Module Pester
12
Describe "New-ModuleFolders" {
23

34
It "Creates expected folders" {

‎Tests/New-ModuleManifestFile.Tests.ps1‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
# Requires -Module Pester
12
Describe "New-ModuleManifestFile" {
23

34
It "Creates a valid manifest" {
4-
$temp = Join-Path $env:TEMP ([guid]::NewGuid().ToString()) "TestModule"
5+
$temp = Join-Path $env:TEMP ([guid]::NewGuid().ToString()) + "TestModule"
56
New-Item -ItemType Directory -Path $temp | Out-Null
67

78
New-ModuleManifestFile -Name "TestModule" -ModulePath $temp

‎Tests/New-ModulePsm1.Tests.ps1‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# Requires -Module Pester
12
Describe "New-ModulePsm1" {
23

34
It "Creates a .psm1 file" {

‎Tests/New-ModuleTemplate.Tests.ps1‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
1+
# Requires -Module Pester
12
Describe "New-ModuleTemplate" {
23

4+
BeforeAll {
5+
# Import the module under test
6+
$moduleRoot = Join-Path $PSScriptRoot '..' | Resolve-Path
7+
$manifest = Join-Path $moduleRoot 'NewModuleTemplate.psd1'
8+
Import-Module $manifest -Force
9+
}
10+
311
It "Creates the correct folder structure" {
412
$temp = Join-Path $env:TEMP ([guid]::NewGuid().ToString())
513
New-Item -ItemType Directory -Path $temp | Out-Null

0 commit comments

Comments
 (0)