Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
e4939c7
feat(mock): implement functions for mocking command parameters using …
rulasg May 25, 2026
71cb2a1
feat(base64): add functions for converting to and from base64
rulasg May 25, 2026
d5cb6f6
feat(base64): add documentation for base64 conversion functions
rulasg May 25, 2026
5f2ad64
refactor(logging): streamline logging functions and add secret removal
rulasg May 25, 2026
420fc2d
feat(Invoke-RestAPI): add support for HTTP methods and request body
rulasg May 25, 2026
8b2c75b
feat(functionParameterHelper): add functions for argument completion …
rulasg Jun 10, 2026
618981d
refactor(Invoke-PrivateContext): change Arguments parameter type from…
rulasg Jun 13, 2026
74903ce
chore: remove sync scripts for TestingHelper templates
rulasg Jun 14, 2026
8a75960
fix(Test-MyDebug): improve testSection function and enhance section h…
rulasg Jun 14, 2026
afda76d
test(MyWrite): update transcript handling for consistency and add new…
rulasg Jun 14, 2026
d5fa22a
fix(Test_CopyIncludeToWorkspace): update test name for consistency
rulasg Jun 14, 2026
240deb0
fix(Find-ModuleRootPath): improve path resolution and handling of mod…
rulasg Jun 14, 2026
47069da
feat(fileversion): implement Update-VersionToFile function for versio…
rulasg Jun 14, 2026
c819903
fix(transcript): use Stop-MyTranscript with array to avoid empty or s…
rulasg Jun 14, 2026
0f4a420
fix(Test_GetIncludeSystemFiles): comment out unused sync files
rulasg Jun 14, 2026
3573afe
fix(Find-ModuleRootPath): copy module.heler.ps1 for consistentcy incl…
rulasg Jun 14, 2026
50661e3
fix(.gitignore): add entry for macOS .DS_Store files and ensure consi…
rulasg Jun 16, 2026
62b8c9f
feat(tests): add Get-IncludeFileVersion and Set-IncludeFileVersion tests
rulasg Jun 16, 2026
a508104
refactor(MyWrite.ps1): improve debug section handling and logging cla…
rulasg Jun 16, 2026
5b750c1
docs(pr-template): clarify instructions for pull request description
rulasg Jun 16, 2026
c7c0a78
feat(mock): add MockCallToBool function for boolean command mocking
rulasg Jun 17, 2026
19b1510
refactor(mock): simplify MockCallExpression by removing unnecessary c…
rulasg Jun 17, 2026
5fbeba3
style(mock): update comments for clarity and maintainability
rulasg Jun 17, 2026
bbe9c11
feat(header): streamline header generation and improve maintainability
rulasg Jun 17, 2026
3a3e07d
fix(header): correct casing in JSON header field
rulasg Jun 17, 2026
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
3 changes: 1 addition & 2 deletions .github/copilot-pull-request-description-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,4 @@ References:

## Pull Request description

- Add a summary of the intention of the PR. Use the title and the messages of the commits to create a summary.
- Add a bullet list with all the commit messages in the PR commits.
- Add a bullet list with all the commit messages in the PR commits. Use the full commit message. Do not remove the Semantic header.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -320,4 +320,7 @@ OpenCover/
ASALocalRun/

# MSBuild Binary and Structured Log
*.binlog
*.binlog

# Mack
**/.DS_Store
16 changes: 15 additions & 1 deletion Test/helper/module.helper.ps1
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# {"Version":"v1.0.0","Date":"2026-06-14"}
#
# Helper for module variables

function Find-ModuleRootPath{
Expand All @@ -7,19 +9,31 @@ function Find-ModuleRootPath{
[string]$Path
)

$path = Convert-Path -Path $Path
$path = Resolve-Path -Path $Path

while (-not [string]::IsNullOrWhiteSpace($Path)){
$psd1 = Get-ChildItem -Path $Path -Filter *.psd1 | Select-Object -First 1

if ($psd1 | Test-Path) {

# Skip if module found is Test
if($psd1.BaseName -eq "Test"){
#foudn testing module. Continue
$path = $path | Split-Path -Parent
continue
}

# It can happen that on a parent folder of a folder there is a lost psd1 file.
# Confirm that the psd1 file name equals the folder name
# Found this bug because on the test machine there was a psd1 on a tempo folder parent of the testing folder.
# This may break modules where the psd1 does not match the folder name
$folderName = Split-Path -Path $path -Leaf
if ($psd1.BaseName -ne $folderName) {
# psd1 file no on folder name
$path = $path | Split-Path -Parent
continue
}

# foudn module
return $path
}
Expand Down
69 changes: 69 additions & 0 deletions Test/include/Mock-SaveParameterToVariable.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Mock-SaveParameterToVariable
#
# Allows mocking commands using a temp varible for the content.
#
# When the parameters for an invoke is too big as string, we can use a json
# as a single parameter to hold all the parameters wanted.
#
# We can use this Mock functions to mock the calls to this invokes that use a json to

Check notice

Code scanning / PSScriptAnalyzer

Line has trailing whitespace Note

Line has trailing whitespace
# transfer an object as parameter.

function Reset-MockSaveParameterToVariable {

Check warning

Code scanning / PSScriptAnalyzer

Function 'Reset-MockSaveParameterToVariable' has verb that could change system state. Therefore, the function has to support 'ShouldProcess'. Warning

Function 'Reset-MockSaveParameterToVariable' has verb that could change system state. Therefore, the function has to support 'ShouldProcess'.

$script:varCommands = @{}
}

function Get-MockSavedParameterFromVariable ($Command){

$result = $script:varCommands[$Command]

if ($nulll -eq $result) {
throw "Command [$Command] was not initialized."
}

return $result

}

function Invoke-MockSaveParameterToVariable{

Check notice

Code scanning / PSScriptAnalyzer

The cmdlet 'Invoke-MockSaveParameterToVariable' does not have a help comment. Note

The cmdlet 'Invoke-MockSaveParameterToVariable' does not have a help comment.
param(
[Parameter(Position=0)][string] $Command,
[Parameter(Position=1)][string] $json,
[Parameter(Position=2)][string] $FileName,
[Parameter()][switch] $ashashtable
)

# Save call to Variable
$script:varCommands.$Command += $json

# Return some value from FielName if provided
if(-Not [string]::IsNullOrWhiteSpace($FileName)){

$ret = Get-MockFileContentJson -filename $FileName -asHashtable:$ashashtable

return $ret
}

} Export-ModuleMember -Function Invoke-MockSaveParameterToVariable

function MockCallJson_SaveParametersToVariable{
param(
[Parameter(Position=0)][string] $command,
[Parameter(Position=2)][string] $fileName,
[Parameter()][switch] $ashashtable
)

# Prepare variable to receive calls
$script:varCommands.$Command = @()

# Mock call back leaving {json} as the parameter to be replaced by the call
$mockCommand = 'Invoke-MockSaveParameterToVariable "{command}" ''{json}'' "{fileName}" -ashashtable:${ashashtable}'
$mockCommand = $mockCommand -replace "{command}", $command
$mockCommand = $mockCommand -replace "{fileName}", $fileName
$mockCommand = $mockCommand -replace "{json}", '{json}'
$mockCommand = $mockCommand -replace "{ashashtable}", $ashashtable.IsPresent.ToString()

# Set invoke command mock with the prepared command
Set-InvokeCommandMock -Alias $command -Command $mockCommand

}
24 changes: 24 additions & 0 deletions Test/include/base64.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
function ConvertTo-Base64 {
[CmdletBinding()]
param (
[Parameter(Mandatory,ValueFromPipeline, Position=0)][string[]]$Text
)

process{
# Encode the string to base64
$ret = [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($Text))
return $ret

Check notice

Code scanning / PSScriptAnalyzer

The cmdlet 'ConvertTo-Base64' returns an object of type 'System.String' but this type is not declared in the OutputType attribute. Note

The cmdlet 'ConvertTo-Base64' returns an object of type 'System.String' but this type is not declared in the OutputType attribute.
}
}

function ConvertFrom-Base64 {
[CmdletBinding()]
param (
[Parameter(Mandatory,ValueFromPipeline, Position=0)][string[]]$Text
)

process{
$ret = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($Text))
return $ret
}
}
2 changes: 1 addition & 1 deletion Test/include/callPrivateContext.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function Invoke-PrivateContext {
[Parameter(Mandatory, Position = 0)]
[scriptblock]$ScriptBlock,
[string]$ModulePath,
[string[]]$Arguments
[object[]]$Arguments
)

if ([string]::IsNullOrEmpty($ModulePath)) {
Expand Down
19 changes: 14 additions & 5 deletions Test/include/invokeCommand.mock.ps1
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# {"Version":"1.0.0","Date":"2026-06-17","HeaderVersion":1}
# DO NOT MODIFY THIS FILE MANUALLY. IT IS GENERATED BY THE IncludeHelper MODULE.
#

# INVOKE COMMAND MOCK
#
Expand Down Expand Up @@ -200,6 +203,17 @@ function MockCallToString{
Set-InvokeCommandMock -Alias $command -Command $outputstring
}

function MockCallToBool{
param(
[Parameter(Position=0)][string] $command,
[Parameter(Position=1)][bool] $OutBool
)

$outputstring = $outBool ? 'return $true' : 'return $false'

Set-InvokeCommandMock -Alias $command -Command $outputstring
}


function MockCallToObject{
param(
Expand Down Expand Up @@ -242,11 +256,6 @@ function MockCallExpression{
[Parameter(Position=1)][string] $expression
)

$mockCommand = @'
Invoke-Expression -Command '{expression}'
'@
$mockCommand = $mockCommand -replace "{expression}", $expression

Set-InvokeCommandMock -Alias $command -Command $expression
}

Expand Down
74 changes: 64 additions & 10 deletions Test/public/MyWrite.test.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
Write-MyHost -Message "This is a test transcript."
}

$result = Stop-MyTranscript
$result = @(Stop-MyTranscript)

Assert-AreEqual -Expected "This is a test transcript." -Presented $result

Expand All @@ -20,7 +20,7 @@
Write-MyHost -Message "This is a test transcript 0"
Write-MyHost -Message "This is a test transcript 1"
}
$result = Stop-MyTranscript
$result = @(Stop-MyTranscript)

Assert-Count -Expected 2 -Presented $result
Assert-AreEqual -Expected "This is a test transcript 0" -Presented $result[0]
Expand Down Expand Up @@ -109,16 +109,14 @@

} -Arguments $text0,$text1

$result = Stop-MyTranscript
$result = @(Stop-MyTranscript)

Assert-Count -Expected 2 -Presented $result
Assert-DbgMsg $result[0] "none" $text0
Assert-DbgMsg $result[1] "none" $text1

}



function Test_EnableMyDebug_All_Sections{

Enable-IncludeHelperDebug
Expand All @@ -136,7 +134,7 @@

} -Arguments $text0,$text1

$result = Stop-MyTranscript
$result = @(Stop-MyTranscript)

Assert-Count -Expected 2 -Presented $result
Assert-DbgMsg $result[0] "section0" $text0
Expand All @@ -162,7 +160,7 @@

} -Arguments $text0,$text1,$text2

$result = Stop-MyTranscript
$result = @(Stop-MyTranscript)

Assert-Count -Expected 2 -Presented $result
Assert-DbgMsg $result[0] "section0" $text0
Expand All @@ -188,7 +186,7 @@

} -Arguments $text0,$text1,$text2

$result = Stop-MyTranscript
$result = @(Stop-MyTranscript)

Assert-Count -Expected 2 -Presented $result
Assert-DbgMsg $result[0] "section0" $text0
Expand Down Expand Up @@ -216,7 +214,7 @@

} -Arguments $text0,$text1,$text2 ,$text3

$result = Stop-MyTranscript
$result = @(Stop-MyTranscript)

Assert-Count -Expected 2 -Presented $result
Assert-DbgMsg $result[0] "section0" $text0
Expand Down Expand Up @@ -247,7 +245,7 @@

} -Arguments $text0,$text1,$text2 ,$text3

$result = Stop-MyTranscript
$result = @(Stop-MyTranscript)

Assert-Count -Expected 4 -Presented $result

Expand All @@ -259,6 +257,62 @@
Assert-DbgMsg $result[3] "section3" $text3
}

function Test_EnableMyDebug_SectionWithAll{

Enable-IncludeHelperDebug -Sections "algoconall"

$text0 = "Debug message 0"
$text1 = "Debug message 1"
$text2 = "Debug message 2"
$text3 = "Debug message 3"

Start-MyTranscript

Invoke-PrivateContext {
param($Arguments)

Check notice

Code scanning / PSScriptAnalyzer

Line has trailing whitespace Note

Line has trailing whitespace
Write-MyDebug -Message $Arguments[0] -Section "section0"
Write-MyDebug -Message $Arguments[1] -Section "section1"
Write-MyDebug -Message $Arguments[2] -Section "algoconall"
Write-MyDebug -Message $Arguments[3] -Section "section3"

} -Arguments $text0,$text1,$text2 ,$text3

$result = @(Stop-MyTranscript)

Assert-Count -Expected 1 -Presented $result
Assert-DbgMsg $result[0] "algoconall" $text2

Check notice

Code scanning / PSScriptAnalyzer

Cmdlet 'Assert-DbgMsg' has positional parameter. Please use named parameters instead of positional parameters when calling a command. Note

Cmdlet 'Assert-DbgMsg' has positional parameter. Please use named parameters instead of positional parameters when calling a command.
}

function Test_EnableMyDebug_SectionUpperCase{

Enable-IncludeHelperDebug -Sections "alGocOnall"

$text0 = "Debug message 0"
$text1 = "Debug message 1"
$text2 = "Debug message 2"
$text3 = "Debug message 3"

Start-MyTranscript

Invoke-PrivateContext {
param($Arguments)

Check notice

Code scanning / PSScriptAnalyzer

Line has trailing whitespace Note

Line has trailing whitespace
Write-MyDebug -Message $Arguments[0] -Section "section0"
Write-MyDebug -Message $Arguments[1] -Section "section1"
Write-MyDebug -Message $Arguments[2] -Section "alGocOnall"
Write-MyDebug -Message $Arguments[3] -Section "algoconall"
Write-MyDebug -Message $Arguments[3] -Section "section3"

} -Arguments $text0,$text1,$text2 ,$text3

$result = @(Stop-MyTranscript)

Assert-Count -Expected 2 -Presented $result
Assert-DbgMsg $result[0] "algoconall" $text2

Check notice

Code scanning / PSScriptAnalyzer

Cmdlet 'Assert-DbgMsg' has positional parameter. Please use named parameters instead of positional parameters when calling a command. Note

Cmdlet 'Assert-DbgMsg' has positional parameter. Please use named parameters instead of positional parameters when calling a command.
Assert-DbgMsg $result[1] "algoconall" $text3

Check notice

Code scanning / PSScriptAnalyzer

Cmdlet 'Assert-DbgMsg' has positional parameter. Please use named parameters instead of positional parameters when calling a command. Note

Cmdlet 'Assert-DbgMsg' has positional parameter. Please use named parameters instead of positional parameters when calling a command.
}

function Assert-DbgMsg($Presented,$Section,$Message){

Assert-IsTrue -Condition ($Presented -match "^\[\d{2}:\d{2}:\d{2}\.\d{3}\]\[IncludeHelper\]\[D\]\[$Section\] $Message$")
Expand Down
2 changes: 1 addition & 1 deletion Test/public/copyIncludeToWorkspace.test.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ function Test_CopyIncludeToWorkspace{
New-ModuleV3 -Name TestModule

# Test for Include
$name = "sync.Helper.ps1"
$name = "deploy.Helper.ps1"
$folderPath = "tools"
$destinationModulePath = "TestModule"

Expand Down
6 changes: 3 additions & 3 deletions Test/public/dependencies.test.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ function Test_ImportDepepency_Import_From_Module_Manager{
Enable-IncludeHelperVerbose
Start-MyTranscript
$output = Import-Dependency -Name $name -Verbose -Confirm:$false
$result = Stop-MyTranscript
$result = @(Stop-MyTranscript)
Disable-IncludeHelperVerbose

#Assert verbose message
Expand Down Expand Up @@ -122,7 +122,7 @@ function Test_ImportDepepency_Install_From_Gallery{
Enable-IncludeHelperVerbose
Start-MyTranscript
$output = Import-Dependency -Name $name -Verbose -Confirm:$false
$result = Stop-MyTranscript
$result = @(Stop-MyTranscript)
Disable-IncludeHelperVerbose

#Assert verbose message
Expand Down Expand Up @@ -157,7 +157,7 @@ function Test_ImportDependency_Clone_From_GitHub{
Enable-IncludeHelperVerbose
Start-MyTranscript
$output = Import-Dependency -Name $name -Verbose -Confirm:$false
$result = Stop-MyTranscript
$result = @(Stop-MyTranscript)
Disable-IncludeHelperVerbose

#Assert verbose message
Expand Down
Loading
Loading