Skip to content
Open
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
2019b68
feat(include): add version and date to include file output
rulasg Jun 17, 2026
ae434ea
chore(header): update version and date in MyWrite.ps1
rulasg Jun 18, 2026
570da8f
fix(datehelper): update command aliases for date retrieval functions
rulasg Jun 18, 2026
341cfec
feat(versioning): implement version header management for include files
rulasg Jun 19, 2026
8de110e
feat(alias): add aliases for Add-IncludeToWorkspace and Get-IncludeFi…
rulasg Jun 24, 2026
5172268
fix(header): update version and date in MyWrite.ps1
rulasg Jun 24, 2026
767d7eb
fix(setfileversion): update parameter attributes for Set-IncludeFileV…
rulasg Jun 24, 2026
13d01ed
chore(header): update header comments in functionParameterHelper.ps1
rulasg Jun 24, 2026
f806a02
fix(githelper): Test-RepoFileChanged
rulasg Jun 25, 2026
7e08b13
fix(tests): remove redundant Reset-InvokeCommandMock call in addInclu…
rulasg Jun 25, 2026
1bb9a21
refactor(version): rename Get-VersionHeader to Get-VersionFromHeader
rulasg Jun 25, 2026
89cc8cb
feat(MyWrite): add Get-ModuleLastError function
rulasg Jun 25, 2026
a7f6a5a
refactor(tests): move Reset-InvokeCommandMock calls from test functio…
rulasg Jul 5, 2026
3e7f59e
feat(invokeCommand): add asynchronous command handling functions
rulasg Jul 5, 2026
3368be1
feat(tests): add mock date helper functions for testing date-related …
rulasg Jul 5, 2026
ef4738b
test(addIncludeToWorkspace): include version header in file assertions
rulasg Jul 5, 2026
147a8aa
feat(test): include source in file version JSON structure
rulasg Jul 5, 2026
362c4fe
feat: add Compare-IncludeFile function for comparing local and remote…
rulasg Jul 5, 2026
7023a57
test: update assertions to include source parameter in file version t…
rulasg Jul 5, 2026
1a6b110
refactor(Get-IncludeFileVersion): simplify return value by directly r…
rulasg Jul 5, 2026
174701a
refactor(tests): unify content retrieval by joining lines in test ass…
rulasg Jul 5, 2026
d43055c
feat(Write-MyDebug): add ObjectNotCompress parameter for debug output
rulasg Jul 5, 2026
dd7ee2e
feat(MyWrite): update version and add InNewLine parameter to Write-My…
rulasg Jul 17, 2026
5c14fb1
feat(Compare-IncludeFile): add OpenDiff parameter to open diffs for u…
rulasg Jul 17, 2026
da9e362
style(MyWrite): add newline for improved readability
rulasg Jul 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
17 changes: 17 additions & 0 deletions Test/include/Mock_datehelper.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

$mockDate = "1975-02-18 00:12:15"
$mockDatetime = [DateTime]::ParseExact($mockDate, 'yyyy-MM-dd HH:mm:ss', $null)
$mockDatetimeUtc = [DateTime]::SpecifyKind($mockDatetime, [DateTimeKind]::Utc)

function Mock_GetToday{

return $mockDatetime

}

function MockCall_DateHelper {

MockCallToObject -command "Get-Date" -OutObject $mockDatetime
MockCallToObject -command "Get-Date -Format 'yyyy-MM-dd'" -OutObject $mockDatetime.ToString("yyyy-MM-dd")
MockCallToObject -command "Get-Date -AsUTC" -OutObject $mockDatetimeUtc
}
2 changes: 1 addition & 1 deletion Test/include/invokeCommand.mock.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ function Get-MockFileContent{

$filePath = Get-MockFileFullPath -fileName $fileName

$content = Get-Content -Path $filePath | Out-String
$content = (Get-Content -Path $filePath) -join "`n"

return $content
} Export-ModuleMember -Function Get-MockFileContent
Expand Down
4 changes: 4 additions & 0 deletions Test/include/run_BeforeAfter.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ function Run_BeforeEach{
# Write-Verbose "Run_BeforeEach"
Disable-IncludeHelperDebug

Reset-InvokeCommandMock

# Mock get the now date
MockCall_DateHelper
}

# function Run_AfterEach{
Expand Down
34 changes: 19 additions & 15 deletions Test/public/addIncludeToWorkspace.test.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ function Test_AddIncludeToWorkspace_IfExists{
$moduleName = "TestModule"
Import-Module -Name TestingHelper

$header = Build-VersionHeader -Version "1.0.0" -Source "IncludeHelper"

# Test for Include
$includefiles = Get-IncludeFile
$include1 = $includefiles | Where-Object { $_.FolderName -eq "Helper" } | Select-Object -First 1
Expand All @@ -97,18 +99,28 @@ function Test_AddIncludeToWorkspace_IfExists{
#Act
$includefiles | Add-IncludeToWorkspace -DestinationModulePath $moduleName -IfExists

#Assert
#Assert check that existing files were updatated
$filesDest1 = Get-ChildItem -Path $destFolder1
Assert-Count -Expected 1 -Presented $filesDest1
$contentFile1 = Get-Content -Path $filesDest1.FullName | Out-String
$sourceFile1 = Get-Content -Path $include1.Path | Out-String
Assert-AreEqual -Expected $sourceFile1.Trim() -Presented $contentFile1.Trim()
$targetFile1 = Get-Content -Path $filesDest1.FullName
$sourceFile1 = (Get-Content -Path $include1.Path)

# Remove the header as they may be different due to the versioning and date of the file
$targetFile1 = (Remove-VersionHeader -Content $targetFile1) -join "`n"
$sourceFile1 = (Remove-VersionHeader -Content $sourceFile1) -join "`n"

Assert-AreEqual -Expected $sourceFile1.Trim() -Presented $targetFile1.Trim()

$filesDest2 = Get-ChildItem -Path $destFolder2
Assert-Count -Expected 1 -Presented $filesDest2
$contentFile2 = Get-Content -Path $filesDest2.FullName | Out-String
$sourceFile2 = Get-Content -Path $include2.Path | Out-String
Assert-AreEqual -Expected $sourceFile2.Trim() -Presented $contentFile2.Trim()
$targetFile2 = Get-Content -Path $filesDest2.FullName
$sourceFile2 = $header + (Get-Content -Path $include2.Path)

# Remove the header as they may be different due to the versioning and date of the file
$targetFile2 = (Remove-VersionHeader -Content $targetFile2) -join "`n"
$sourceFile2 = (Remove-VersionHeader -Content $sourceFile2) -join "`n"

Assert-AreEqual -Expected $sourceFile2.Trim() -Presented $targetFile2.Trim()
}

function Test_AddIncludeToWorkspace_PipeParameters{
Expand All @@ -134,13 +146,10 @@ function Test_AddIncludeToWorkspace_PipeParameters{
$folderNamePath = get-Modulefolder -FolderName "TestInclude" -ModuleRootPath $destinationModulePath
$path = $folderNamePath | Join-Path -ChildPath "config.mock.ps1"
Assert-ItemExist -path $path

}

function Test_AddIncludeToWorkspace_WithoutSource_WithoutDestination{

Reset-InvokeCommandMock

Import-Module -Name TestingHelper
New-ModuleV3 -Name TestModule

Expand All @@ -150,7 +159,6 @@ function Test_AddIncludeToWorkspace_WithoutSource_WithoutDestination{
$destinationFilePath = $destinationPath | Join-Path -ChildPath $destinationName
Remove-Item -Path $destinationFilePath -ErrorAction SilentlyContinue


# Act
Assert-itemNotExist -path $destinationFilePath

Expand All @@ -164,8 +172,6 @@ function Test_AddIncludeToWorkspace_WithoutSource_WithoutDestination{

function Test_AddIncludeToWorkspace_FromSourceToDestination{

Reset-InvokeCommandMock

$TargetModuleName = "TargetModule"
$SourceModuleName = "SourceModule"

Expand Down Expand Up @@ -198,8 +204,6 @@ function Test_AddIncludeToWorkspace_FromSourceToDestination{
# With soruce not destination
function Test_AddIncludeToWorkspace_FromSourceToDestination_WithoutDestination{

Reset-InvokeCommandMock

$FileName1 = "MyInclude1.ps1"
$FileName2 = "MyInclude2.ps1"

Expand Down
5 changes: 1 addition & 4 deletions Test/public/callAPI.test.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
function Test_CallAPI_RESTAPI_Withpagination_1{

Assert-SkipTest "This test is not implemented"
Reset-InvokeCommandMock

Enable-InvokeCommandAliasModule

# Act
Expand All @@ -20,7 +20,6 @@ function Test_CallAPI_RESTAPI_Withpagination_2{

Assert-SkipTest "This test is not implemented"

Reset-InvokeCommandMock
Enable-InvokeCommandAliasModule

# Act
Expand All @@ -34,7 +33,6 @@ function Test_Call_API_GraphQL{

Assert-SkipTest "This test is not implemented"

Reset-InvokeCommandMock
Enable-InvokeCommandAliasModule

$query = @'
Expand All @@ -54,7 +52,6 @@ function Test_Call_API_GraphQL_outfile{

Assert-SkipTest "This test is not implemented"

Reset-InvokeCommandMock
Enable-InvokeCommandAliasModule

$file = "outfile.json"
Expand Down
6 changes: 0 additions & 6 deletions Test/public/databasev2.test.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@

function Test_Database{

Reset-InvokeCommandMock
Mock_Database -ResetDatabase

# Load include files needed to test database
Expand Down Expand Up @@ -47,7 +46,6 @@ function Test_Database{

function Test_Database_JSON{

Reset-InvokeCommandMock
Mock_Database -ResetDatabase

# Load include files needed to test database
Expand Down Expand Up @@ -93,7 +91,6 @@ function Test_Database_JSON{

function Test_Database_JSON_ComplexObject{

Reset-InvokeCommandMock
Mock_Database -ResetDatabase

# Load include files needed to test database
Expand Down Expand Up @@ -133,7 +130,6 @@ function Test_Database_JSON_ComplexObject{

function Test_Database_XML{

Reset-InvokeCommandMock
Mock_Database -ResetDatabase

# Load include files needed to test database
Expand Down Expand Up @@ -179,7 +175,6 @@ function Test_Database_XML{

function Test_Database_TXT{

Reset-InvokeCommandMock
Mock_Database -ResetDatabase

# Load include files needed to test database
Expand Down Expand Up @@ -225,7 +220,6 @@ function Test_Database_TXT{

function Test_Database_MultyKey{

Reset-InvokeCommandMock
Mock_Database -ResetDatabase

. $(Get-Ps1FullPath -Name "databaseV2.ps1" -FolderName "Include" -ModuleRootPath $MODULE_ROOT_PATH)
Expand Down
24 changes: 13 additions & 11 deletions Test/public/datehelper.test.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,23 @@ function Test_GetDaysBetweenDates_OneYear {
}

function Test_GetDaysBetweenDates_DefaultStartDate {

# Arrange
Reset-InvokeCommandMock

$now = Get-Date -Format 'yyyy-MM-dd'
MockCallToObject -Command "GetNow" -OutObject $now
$futureDate = (Mock_GetToday).AddDays(10)
$futureDateString = $futureDate | Get-Date -Format 'yyyy-MM-dd'

# Act & Assert
Invoke-PrivateContext {
$futureDate = (Get-Date).AddDays(10) | Get-Date -Format 'yyyy-MM-dd'

$result = Get-DaysBetweenDates -EndDate $futureDate

# Result should be approximately 10 days (allowing for same-day test execution)
Assert-AreEqual -Expected 10 -Presented $result
}
# Act
$result = Invoke-PrivateContext {
param($Arguments)

Get-DaysBetweenDates -EndDate $Arguments[0]

} -Arguments $futureDateString

# Result should be approximately 10 days (allowing for same-day test execution)
Assert-AreEqual -Expected 10 -Presented $result
}

function Test_ConvertFromEpochTime_OneDay {
Expand Down
6 changes: 0 additions & 6 deletions Test/public/dependencies.test.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
function Test_ImportDepepency_Already_loaded{

$name = "TargetModule" ; $modulesFolder = "ModulesFolder"
Reset-InvokeCommandMock
New-moduleV3 -Name $name -Path $modulesFolder


Expand All @@ -27,7 +26,6 @@ function Test_ImportDepepency_Already_loaded{
function Test_ImportDepepency_SideBySide{

$name = "TargetModule" ; $modulesFolder = "ModulesFolder"
Reset-InvokeCommandMock

# Create new module on test folder
New-moduleV3 -Name $name -Path $modulesFolder
Expand Down Expand Up @@ -59,8 +57,6 @@ function Test_ImportDepepency_Import_From_Module_Manager{

$name = "TargetModule" ; $modulesFolder = "ModulesFolder"

Reset-InvokeCommandMock

New-ModuleV3 -Name $name -Path $modulesFolder

# Mock Get-Module to Null
Expand Down Expand Up @@ -92,7 +88,6 @@ function Test_ImportDepepency_Import_From_Module_Manager{
function Test_ImportDepepency_Install_From_Gallery{

$name = "TargetModule" ; $modulesFolder = "ModulesFolder"
Reset-InvokeCommandMock
New-ModuleV3 -Name $name -Path $modulesFolder

# Mock Get-Module to Null
Expand Down Expand Up @@ -134,7 +129,6 @@ function Test_ImportDependency_Clone_From_GitHub{

$name = "TargetModule" ; $modulesFolder = "ModulesFolder"
$owner = "rulasg"
Reset-InvokeCommandMock

# Mock Get-Module to Null
Mock_GetModule_Null -Name $name
Expand Down
15 changes: 9 additions & 6 deletions Test/public/getfileversion.test.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,13 @@ function Test_GetFileVersion_EmptyFile{

function Test_GetFileVersion_NoVersion{


New-Testingfile -Name "TestFile.ps1" -Content $FILE_FACKE_CONTENT

# Act
$result = Get-IncludeFileVersion -Path "TestFile.ps1"

# Assert
Assert-IsNull -Object $result

}

function Test_GetFileVersion_OnlyVersion{
Expand All @@ -27,7 +25,9 @@ function Test_GetFileVersion_OnlyVersion{
$headerversion = 1
$version = "1.0.0"
$date = "1975-02-18"
$json = Build-TestFileVersionJson $Version $Date $headerversion
$source = "IncludeHelper"

$json = Build-TestFileVersionJson $Version $Date $source $headerversion
New-Testingfile -Name "TestFile.ps1" -Content $("# $json")
Assert-FileVersion -Path "TestFile.ps1" -Version $version -Date $date

Expand All @@ -38,6 +38,8 @@ function Test_GetFileVersion_OnlyVersion{
Assert-IsNotNull -Object $result
Assert-AreEqual -Expected $version -Presented $result.Version
Assert-AreEqual -Expected $date -Presented $result.Date
Assert-AreEqual -Expected $source -Presented $result.Source
Assert-AreEqual -Expected $headerversion -Presented $result.HeaderVersion
}

function Test_GetFileVersion_VersionAndBody{
Expand All @@ -46,11 +48,12 @@ function Test_GetFileVersion_VersionAndBody{
$headerversion = 1
$version = "1.0.0"
$date = "1975-02-18"
$header = Build-TestVersionHeader $Version $Date $headerversion
$source = "IncludeHelper"
$header = Build-TestVersionHeader $Version $Date $source $headerversion
$body = $FILE_FACKE_CONTENT
$content = $header + $body | Out-String
$content = ($header + $body) -join "`n"
New-Testingfile -Name "TestFile.ps1" -Content $content
Assert-FileVersion -Path "TestFile.ps1" -Version $version -Date $date -Body $body
Assert-FileVersion -Path "TestFile.ps1" -Version $version -Date $date -Body $body

# Act
$result = Get-IncludeFileVersion -Path "TestFile.ps1"
Expand Down
38 changes: 38 additions & 0 deletions Test/public/githelper.test.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
function Test_TestRepoFileChanged_Changed{


$repo = "reponame"
New-TestingFolder -Path $repo
git init $repo

# Arrange Not changed
$folder = "folder1/folder2"
$file = "file1.txt"
New-TestingFile -Path "$repo/$folder" -Name $file -Content "Hello World"
$targetpath = Join-Path -Path $repo -childPath $folder -AdditionalChildPath $file

# Act
$result = Test-RepoFileChanged -Path $targetpath

# Assert
Assert-IsTrue -Condition $result

# Arrange Not Changed
git -C $repo add .
git -C $repo commit -m "Initial commit"

# Act
$result = Test-RepoFileChanged -Path $targetpath

# Assert
Assert-IsFalse -Condition $result -Comment "File should not be marked as changed after commit"

# Arrange change the file again
Set-Content -Path $targetpath -Value "Hello World Changed"

# Act
$result = Test-RepoFileChanged -Path $targetpath

# Assert
Assert-IsTrue -Condition $result -Comment "File should be marked as changed after modification"
}
Loading
Loading