Skip to content

Commit 2f39c36

Browse files
committed
Refreshing
1 parent 17c0071 commit 2f39c36

File tree

3 files changed

+47
-16
lines changed

3 files changed

+47
-16
lines changed

TestingModule/TestingModule.psd1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#
1+
#
22
# Module manifest for module 'TestingModule'
33
#
44
# Generated by: Lars Panzerbjørn
@@ -130,3 +130,4 @@ PrivateData = @{
130130

131131
}
132132

133+

Tests/Module.Test.ps1

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1+
$ProjectRoot = (Resolve-Path "$PSScriptRoot\..").path
2+
$ModuleName = Split-Path $ProjectRoot -Leaf
3+
$ModuleRoot = Join-Path -Path $ProjectRoot -ChildPath $ModuleName -AdditionalChildPath "$ModuleName.psm1"
4+
$ManifestRoot = Join-Path -Path $ProjectRoot -ChildPath $ModuleName -AdditionalChildPath "$ModuleName.psd1"
5+
$Functions = Join-Path -Path $ProjectRoot -ChildPath $ModuleName -AdditionalChildPath Functions
6+
$Helpers = Join-Path -Path $ProjectRoot -ChildPath $ModuleName -AdditionalChildPath Helpers
7+
18
BeforeAll {
9+
#Write-Host 'BeforeAll'
210
Try{
311
Import-module PSScriptAnalyzer -ErrorAction STOP
412
}
@@ -9,7 +17,6 @@ BeforeAll {
917
Install-Module -Name PSScriptAnalyzer -Force
1018
}
1119

12-
#$Scripts = Get-ChildItem -Include *.ps1 -Exclude *WiP.ps1 -Recurse
1320
$ProjectRoot = (Resolve-Path "$PSScriptRoot\..").path
1421
$ModuleName = Split-Path $ProjectRoot -Leaf
1522
$ModuleRoot = Join-Path -Path $ProjectRoot -ChildPath $ModuleName -AdditionalChildPath "$ModuleName.psm1"
@@ -22,6 +29,8 @@ Describe "General project validation: $ModuleName" -Tag 'Module_Validation' {
2229

2330
Context 'Project should be viable' {
2431

32+
#Write-Host 'Context: Project should be viable'
33+
2534
It "Test-Path $ProjectRoot should be True" {
2635
Test-Path $ProjectRoot | Should -Be $True
2736
}
@@ -37,20 +46,18 @@ Describe "General project validation: $ModuleName" -Tag 'Module_Validation' {
3746
it 'Passes all default PSScriptAnalyzer rules' {
3847
Invoke-ScriptAnalyzer -Path $ManifestRoot -ExcludeRule PSUseToExportFieldsInManifest | should -BeNullOrEmpty
3948
}
40-
41-
4249
}
4350
}
4451

4552
Describe "Validating commands are viable" -Tag 'Command_Validation' {
4653

4754
Context 'Public functions should be viable' {
55+
#Write-Host 'Context: Public functions should be viable'
4856

49-
BeforeAll {
50-
$AllFunctions = Get-ChildItem -Path $Functions -Include *.ps1 -Recurse
51-
$TestCase = $AllFunctions | Foreach-Object {@{file=$_}}
52-
}
53-
57+
#Write-Host "Functions path: $Functions"
58+
$AllFunctions = Get-ChildItem -Path $Functions -Include *.ps1 -Recurse
59+
$TestCase = $AllFunctions | Foreach-Object {@{file=$_}}
60+
#Write-Host "Test cases generated: $($TestCase | Out-String)"
5461

5562
It "Script <file> should be valid powershell" -TestCases $TestCase {
5663
param($File)
@@ -94,10 +101,10 @@ Describe "Validating commands are viable" -Tag 'Command_Validation' {
94101

95102
Context 'Private helpers should be viable' {
96103

97-
BeforeAll {
98-
$AllHelpers = Get-ChildItem -Path $Functions -Include *.ps1 -Recurse
99-
$TestCase = $AllHelpers | Foreach-Object {@{file=$_}}
100-
}
104+
#Write-Host 'Context: Private helpers should be viable'
105+
$AllHelpers = Get-ChildItem -Path $Functions -Include *.ps1 -Recurse
106+
$TestCase = $AllHelpers | Foreach-Object {@{file=$_}}
107+
#Write-Host "Test cases generated: $($TestCase | Out-String)"
101108

102109
It "Script <file> should be valid powershell" -TestCases $TestCase {
103110
param($File)
@@ -115,8 +122,5 @@ Describe "Validating commands are viable" -Tag 'Command_Validation' {
115122
param($File)
116123
Test-Path $File.Fullname | Should -Be $True
117124
}
118-
119-
120125
}
121-
122126
}

Tests/Vars.ps1

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
cls
2+
$ProjectRoot = (Resolve-Path "$PSScriptRoot\..").path
3+
$ModuleName = Split-Path $ProjectRoot -Leaf
4+
$ModuleRoot = Join-Path -Path $ProjectRoot -ChildPath $ModuleName -AdditionalChildPath "$ModuleName.psm1"
5+
$ManifestRoot = Join-Path -Path $ProjectRoot -ChildPath $ModuleName -AdditionalChildPath "$ModuleName.psd1"
6+
$Functions = Join-Path -Path $ProjectRoot -ChildPath $ModuleName -AdditionalChildPath Functions
7+
$Helpers = Join-Path -Path $ProjectRoot -ChildPath $ModuleName -AdditionalChildPath Helpers
8+
$AllFunctions = Get-ChildItem -Path $Functions -Include *.ps1 -Recurse
9+
$AllHelpers = Get-ChildItem -Path $Helpers -Include *.ps1 -Recurse
10+
11+
$ProjectRoot
12+
$ModuleName
13+
$ModuleRoot
14+
$ManifestRoot
15+
$Functions
16+
$Helpers
17+
18+
"AllFunctions:"
19+
$AllFunctions
20+
#$AllFunctions.Fullname
21+
"AllHelpers"
22+
$AllHelpers
23+
$AllHelpers.Fullname
24+
#$AllFunctions | Foreach-Object {@{file=$_}}
25+
$AllFunctions | Foreach-Object {@{file=$_}}
26+
$AllHelpers | Foreach-Object {@{file=$_}}

0 commit comments

Comments
 (0)