Skip to content
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
2 changes: 1 addition & 1 deletion .github/copilot-commit-message-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ References:

- https://www.conventionalcommits.org/
- https://seesparkbox.com/foundry/semantic_commit_messages
- http://karma-runner.github.io/1.0/dev/git-commit-msg.html
- http://karma-runner.github.io/1.0/dev/git-commit-msg.html
2 changes: 1 addition & 1 deletion Test/Test.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ $MODULE_PATH = $PSScriptRoot
catch { Write-Error -Message "Failed to import $($import.fullname): $_" }
}
}
Export-ModuleMember -Function Test_*
Export-ModuleMember -Function Test_*
121 changes: 70 additions & 51 deletions Test/helper/module.helper.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,45 @@ $MODULE_NAME = (Get-ChildItem -Path $MODULE_ROOT_PATH -Filter *.psd1 | Select-Ob

# Helper for module variables


$VALID_FOLDER_NAMES = @('Include', 'Private', 'Public', 'Root', 'TestInclude', 'TestPrivate', 'TestPublic', 'TestRoot', 'Tools', 'DevContainer', 'WorkFlows', 'GitHub', 'Helper', 'Config', 'TestHelper', 'TestConfig')
# Folders names that IncludeHelper may add content to
$VALID_INCLUDE_FOLDER_NAMES = @(
'Root',
'Include',
'DevContainer',
'WorkFlows',
'GitHub',
# 'Config',
'Helper',
# 'Private',
# 'Public',
'Tools',

'TestRoot',
# 'TestConfig'
'TestInclude',
'TestHelper',
# 'TestPrivate',
# 'TestPublic',

"TestHelperRoot",
"TestHelperPrivate",
"TestHelperPublic"

"VsCode"
)

# Folders names that IncludeHelper should not add content to.
# In this folders is the module code itself
$VALID_MODULE_FOLDER_NAMES = @(
'Config',
'Private',
'Public',
'TestConfig'
'TestPrivate',
'TestPublic'
)

$VALID_FOLDER_NAMES = $VALID_INCLUDE_FOLDER_NAMES + $VALID_MODULE_FOLDER_NAMES

class ValidFolderNames : System.Management.Automation.IValidateSetValuesGenerator {
[String[]] GetValidValues() {
Expand Down Expand Up @@ -113,59 +150,41 @@ function Get-ModuleFolder{

# TestRootPath
$testRootPath = $ModuleRootPath | Join-Path -ChildPath "Test"
$testHelperRootPath = $ModuleRootPath | Join-Path -ChildPath "tools/Test_Helper"

switch ($FolderName){
'Public'{
$moduleFolder = $ModuleRootPath | Join-Path -ChildPath "public"
}
'Private'{
$moduleFolder = $ModuleRootPath | Join-Path -ChildPath "private"
}
'Include'{
$moduleFolder = $ModuleRootPath | Join-Path -ChildPath "include"
}
'TestInclude'{
$moduleFolder = $testRootPath | Join-Path -ChildPath "include"
}
'TestPrivate'{
$moduleFolder = $testRootPath | Join-Path -ChildPath "private"
}
'TestPublic'{
$moduleFolder = $testRootPath | Join-Path -ChildPath "public"
}
'Root'{
$moduleFolder = $ModuleRootPath
}
'TestRoot'{
$moduleFolder = $testRootPath
}
'Tools'{
$moduleFolder = $ModuleRootPath | Join-Path -ChildPath "tools"
}
'DevContainer'{
$moduleFolder = $ModuleRootPath | Join-Path -ChildPath ".devcontainer"
}
'WorkFlows'{
$moduleFolder = $ModuleRootPath | Join-Path -ChildPath ".github/workflows"
}
'GitHub'{
$moduleFolder = $ModuleRootPath | Join-Path -ChildPath ".github"
}
'Helper'{
$moduleFolder = $ModuleRootPath | Join-Path -ChildPath "helper"
}
'Config'{
$moduleFolder = $ModuleRootPath | Join-Path -ChildPath "config"
}
'TestHelper'{
$moduleFolder = $testRootPath | Join-Path -ChildPath "helper"
}
'TestConfig'{
$moduleFolder = $testRootPath | Join-Path -ChildPath "config"
}

# VALID_INCLUDE_FOLDER_NAMES
'Root' { $moduleFolder = $ModuleRootPath }
'Include' { $moduleFolder = $ModuleRootPath | Join-Path -ChildPath "include" }
'DevContainer'{ $moduleFolder = $ModuleRootPath | Join-Path -ChildPath ".devcontainer" }
'WorkFlows' { $moduleFolder = $ModuleRootPath | Join-Path -ChildPath ".github/workflows" }
'GitHub' { $moduleFolder = $ModuleRootPath | Join-Path -ChildPath ".github" }
'Helper' { $moduleFolder = $ModuleRootPath | Join-Path -ChildPath "helper" }
'Tools' { $moduleFolder = $ModuleRootPath | Join-Path -ChildPath "tools" }

'TestRoot' { $moduleFolder = $testRootPath }
'TestInclude' { $moduleFolder = $testRootPath | Join-Path -ChildPath "include" }
'TestHelper' { $moduleFolder = $testRootPath | Join-Path -ChildPath "helper" }

'TestHelperRoot' { $moduleFolder = $testHelperRootPath }
'TestHelperPrivate' { $moduleFolder = $testHelperRootPath | Join-Path -ChildPath "private" }
'TestHelperPublic' { $moduleFolder = $testHelperRootPath | Join-Path -ChildPath "public" }

"VsCode" { $moduleFolder = $ModuleRootPath | Join-Path -ChildPath ".vscode" }

# VALID_MODULE_FOLDER_NAMES
'Config' { $moduleFolder = $ModuleRootPath | Join-Path -ChildPath "config" }
'Private' { $moduleFolder = $ModuleRootPath | Join-Path -ChildPath "private" }
'Public' { $moduleFolder = $ModuleRootPath | Join-Path -ChildPath "public" }
'TestConfig' { $moduleFolder = $testRootPath | Join-Path -ChildPath "config" }
'TestPrivate' { $moduleFolder = $testRootPath | Join-Path -ChildPath "private" }
'TestPublic' { $moduleFolder = $testRootPath | Join-Path -ChildPath "public" }


default{
throw "Folder [$FolderName] is unknown"
}
}
return $moduleFolder
} Export-ModuleMember -Function Get-ModuleFolder
} Export-ModuleMember -Function Get-ModuleFolder
6 changes: 6 additions & 0 deletions Test/include/InvokeMockList.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ function Trace-MockCommandFile{
}

function readMockCommandFile{

# Return empty list if the file does not exist
if(-not (Test-Path -Path $MockCommandFile)){
return @()
}

$ret = Get-Content -Path $MockCommandFile | ConvertFrom-Json

# return an empty aray if content does not exists
Expand Down
6 changes: 3 additions & 3 deletions Test/include/config.mock.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
if(-not $MODULE_NAME){ throw "Missing MODULE_NAME varaible initialization. Check for module.helerp.ps1 file." }

$MOCK_CONFIG_PATH = "test_config_path"
$CONFIG_INVOKE_GET_ROOT_PATH_CMD = "Invoke-ProjectHelperGetConfigRootPath"
$CONFIG_INVOKE_GET_ROOT_PATH_CMD = "Invoke-{modulename}GetConfigRootPath"

function Mock_Config{
param(
Expand Down Expand Up @@ -40,9 +40,9 @@ function Mock_Config{
$moduleName = $MODULE_NAME
}

$invokefunction = $CONFIG_INVOKE_GET_ROOT_PATH_CMD -replace "ProjectHelper", $moduleName
$invokefunction = $CONFIG_INVOKE_GET_ROOT_PATH_CMD -replace "{modulename}", $moduleName

# Mock invoke call
MockCallToString $invokefunction -OutString $fullpath

}
}
23 changes: 17 additions & 6 deletions Test/include/invokeCommand.mock.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,32 @@ $testRootPath = $MODULE_ROOT_PATH | Join-Path -ChildPath 'Test'
$MOCK_PATH = $testRootPath | Join-Path -ChildPath 'private' -AdditionalChildPath 'mocks'

$MODULE_INVOKATION_TAG = "$($MODULE_NAME)Module"
$MODULE_INVOKATION_TEST_TAG = "$($MODULE_NAME)TestModule"
$MODULE_INVOKATION_TAG_MOCK = "$($MODULE_INVOKATION_TAG)_Mock"

$TraceInvokeMock = $testRootPath | Join-Path -ChildPath "traceInvoke.log"
$TraceInvokeFilePathCommand = "Get-$($MODULE_NAME)TraceInvokeFilePath"

function Invoke-ModuleNameGetTraceInvokeFilePath{
[CmdletBinding()]
param()

$filePath = $testRootPath | Join-Path -ChildPath "traceInvoke.log"

return $filePath
}
Copy-Item -path Function:Invoke-ModuleNameGetTraceInvokeFilePath -Destination Function:"Invoke-$($MODULE_NAME)GetTraceInvokeFilePath"
Export-ModuleMember -Function "Invoke-$($MODULE_NAME)GetTraceInvokeFilePath"
InvokeHelper\Set-InvokeCommandAlias -Alias $TraceInvokeFilePathCommand -Command "Invoke-$($MODULE_NAME)GetTraceInvokeFilePath" -Tag $MODULE_INVOKATION_TEST_TAG

function Trace-InvokeCommandAlias{
[CmdletBinding()]
param(
[Parameter(Mandatory,Position=0)][string]$Alias
)

$filePath = $TraceInvokeMock
$filePath = Invoke-MyCommand -Command $TraceInvokeFilePathCommand

if(! $filePath){ return }

# if(! (Test-Path $filePath)) {return}
if(! (Test-Path $filePath)) {return}

$content = Get-Content $filePath

Expand Down Expand Up @@ -292,4 +303,4 @@ function Assert-MockFileNotfound{
Wait-Debugger
throw "File not found or wrong case name. Expected[ $filename ] - Found[$( $file.name )]"
}
}
}
2 changes: 1 addition & 1 deletion Test/include/transcriptHelp.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function Export-MyTranscript {
[CmdletBinding()]
param (
[Parameter(Mandatory, Position = 0)]
[array]$transcriptContent
[object[]]$transcriptContent
)

$i = 0..($transcriptContent.Count - 1) | Where-Object { $transcriptContent[$_] -eq "**********************" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@
# - Before all tests
# - After all tests

function Run_BeforeAll{
Write-Verbose "Run_BeforeAll"
}
# function Run_BeforeAll{
# Write-Verbose "Run_BeforeAll"
# }

function Run_AfterAll{
Write-Verbose "Run_AfterAll"
}
# function Run_AfterAll{
# Write-Verbose "Run_AfterAll"
# }

function Run_BeforeEach{
Write-Verbose "Run_BeforeEach"

Reset_Test_Mock
Reset_Test_Mock
}

function Run_AfterEach{
Write-Verbose "Run_AfterEach"
}
# function Run_AfterEach{
# Write-Verbose "Run_AfterEach"
# }

Export-ModuleMember -Function Run_*
Loading
Loading