Skip to content

Commit 531e941

Browse files
authored
Merge pull request #186 from rulasg/sync-includefiles
feat(sync-include): Update include modules from includehelper
2 parents 0e84dfa + 54b21c7 commit 531e941

11 files changed

Lines changed: 235 additions & 128 deletions

.github/copilot-commit-message-instructions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ References:
3131

3232
- https://www.conventionalcommits.org/
3333
- https://seesparkbox.com/foundry/semantic_commit_messages
34-
- http://karma-runner.github.io/1.0/dev/git-commit-msg.html
34+
- http://karma-runner.github.io/1.0/dev/git-commit-msg.html

Test/Test.psm1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ $MODULE_PATH = $PSScriptRoot
1010
catch { Write-Error -Message "Failed to import $($import.fullname): $_" }
1111
}
1212
}
13-
Export-ModuleMember -Function Test_*
13+
Export-ModuleMember -Function Test_*

Test/helper/module.helper.ps1

Lines changed: 70 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,45 @@ $MODULE_NAME = (Get-ChildItem -Path $MODULE_ROOT_PATH -Filter *.psd1 | Select-Ob
3636

3737
# Helper for module variables
3838

39-
40-
$VALID_FOLDER_NAMES = @('Include', 'Private', 'Public', 'Root', 'TestInclude', 'TestPrivate', 'TestPublic', 'TestRoot', 'Tools', 'DevContainer', 'WorkFlows', 'GitHub', 'Helper', 'Config', 'TestHelper', 'TestConfig')
39+
# Folders names that IncludeHelper may add content to
40+
$VALID_INCLUDE_FOLDER_NAMES = @(
41+
'Root',
42+
'Include',
43+
'DevContainer',
44+
'WorkFlows',
45+
'GitHub',
46+
# 'Config',
47+
'Helper',
48+
# 'Private',
49+
# 'Public',
50+
'Tools',
51+
52+
'TestRoot',
53+
# 'TestConfig'
54+
'TestInclude',
55+
'TestHelper',
56+
# 'TestPrivate',
57+
# 'TestPublic',
58+
59+
"TestHelperRoot",
60+
"TestHelperPrivate",
61+
"TestHelperPublic"
62+
63+
"VsCode"
64+
)
65+
66+
# Folders names that IncludeHelper should not add content to.
67+
# In this folders is the module code itself
68+
$VALID_MODULE_FOLDER_NAMES = @(
69+
'Config',
70+
'Private',
71+
'Public',
72+
'TestConfig'
73+
'TestPrivate',
74+
'TestPublic'
75+
)
76+
77+
$VALID_FOLDER_NAMES = $VALID_INCLUDE_FOLDER_NAMES + $VALID_MODULE_FOLDER_NAMES
4178

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

114151
# TestRootPath
115152
$testRootPath = $ModuleRootPath | Join-Path -ChildPath "Test"
153+
$testHelperRootPath = $ModuleRootPath | Join-Path -ChildPath "tools/Test_Helper"
116154

117155
switch ($FolderName){
118-
'Public'{
119-
$moduleFolder = $ModuleRootPath | Join-Path -ChildPath "public"
120-
}
121-
'Private'{
122-
$moduleFolder = $ModuleRootPath | Join-Path -ChildPath "private"
123-
}
124-
'Include'{
125-
$moduleFolder = $ModuleRootPath | Join-Path -ChildPath "include"
126-
}
127-
'TestInclude'{
128-
$moduleFolder = $testRootPath | Join-Path -ChildPath "include"
129-
}
130-
'TestPrivate'{
131-
$moduleFolder = $testRootPath | Join-Path -ChildPath "private"
132-
}
133-
'TestPublic'{
134-
$moduleFolder = $testRootPath | Join-Path -ChildPath "public"
135-
}
136-
'Root'{
137-
$moduleFolder = $ModuleRootPath
138-
}
139-
'TestRoot'{
140-
$moduleFolder = $testRootPath
141-
}
142-
'Tools'{
143-
$moduleFolder = $ModuleRootPath | Join-Path -ChildPath "tools"
144-
}
145-
'DevContainer'{
146-
$moduleFolder = $ModuleRootPath | Join-Path -ChildPath ".devcontainer"
147-
}
148-
'WorkFlows'{
149-
$moduleFolder = $ModuleRootPath | Join-Path -ChildPath ".github/workflows"
150-
}
151-
'GitHub'{
152-
$moduleFolder = $ModuleRootPath | Join-Path -ChildPath ".github"
153-
}
154-
'Helper'{
155-
$moduleFolder = $ModuleRootPath | Join-Path -ChildPath "helper"
156-
}
157-
'Config'{
158-
$moduleFolder = $ModuleRootPath | Join-Path -ChildPath "config"
159-
}
160-
'TestHelper'{
161-
$moduleFolder = $testRootPath | Join-Path -ChildPath "helper"
162-
}
163-
'TestConfig'{
164-
$moduleFolder = $testRootPath | Join-Path -ChildPath "config"
165-
}
156+
157+
# VALID_INCLUDE_FOLDER_NAMES
158+
'Root' { $moduleFolder = $ModuleRootPath }
159+
'Include' { $moduleFolder = $ModuleRootPath | Join-Path -ChildPath "include" }
160+
'DevContainer'{ $moduleFolder = $ModuleRootPath | Join-Path -ChildPath ".devcontainer" }
161+
'WorkFlows' { $moduleFolder = $ModuleRootPath | Join-Path -ChildPath ".github/workflows" }
162+
'GitHub' { $moduleFolder = $ModuleRootPath | Join-Path -ChildPath ".github" }
163+
'Helper' { $moduleFolder = $ModuleRootPath | Join-Path -ChildPath "helper" }
164+
'Tools' { $moduleFolder = $ModuleRootPath | Join-Path -ChildPath "tools" }
165+
166+
'TestRoot' { $moduleFolder = $testRootPath }
167+
'TestInclude' { $moduleFolder = $testRootPath | Join-Path -ChildPath "include" }
168+
'TestHelper' { $moduleFolder = $testRootPath | Join-Path -ChildPath "helper" }
169+
170+
'TestHelperRoot' { $moduleFolder = $testHelperRootPath }
171+
'TestHelperPrivate' { $moduleFolder = $testHelperRootPath | Join-Path -ChildPath "private" }
172+
'TestHelperPublic' { $moduleFolder = $testHelperRootPath | Join-Path -ChildPath "public" }
173+
174+
"VsCode" { $moduleFolder = $ModuleRootPath | Join-Path -ChildPath ".vscode" }
175+
176+
# VALID_MODULE_FOLDER_NAMES
177+
'Config' { $moduleFolder = $ModuleRootPath | Join-Path -ChildPath "config" }
178+
'Private' { $moduleFolder = $ModuleRootPath | Join-Path -ChildPath "private" }
179+
'Public' { $moduleFolder = $ModuleRootPath | Join-Path -ChildPath "public" }
180+
'TestConfig' { $moduleFolder = $testRootPath | Join-Path -ChildPath "config" }
181+
'TestPrivate' { $moduleFolder = $testRootPath | Join-Path -ChildPath "private" }
182+
'TestPublic' { $moduleFolder = $testRootPath | Join-Path -ChildPath "public" }
183+
184+
166185
default{
167186
throw "Folder [$FolderName] is unknown"
168187
}
169188
}
170189
return $moduleFolder
171-
} Export-ModuleMember -Function Get-ModuleFolder
190+
} Export-ModuleMember -Function Get-ModuleFolder

Test/include/InvokeMockList.ps1

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ function Trace-MockCommandFile{
3030
}
3131

3232
function readMockCommandFile{
33+
34+
# Return empty list if the file does not exist
35+
if(-not (Test-Path -Path $MockCommandFile)){
36+
return @()
37+
}
38+
3339
$ret = Get-Content -Path $MockCommandFile | ConvertFrom-Json
3440

3541
# return an empty aray if content does not exists

Test/include/config.mock.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
if(-not $MODULE_NAME){ throw "Missing MODULE_NAME varaible initialization. Check for module.helerp.ps1 file." }
1010

1111
$MOCK_CONFIG_PATH = "test_config_path"
12-
$CONFIG_INVOKE_GET_ROOT_PATH_CMD = "Invoke-ProjectHelperGetConfigRootPath"
12+
$CONFIG_INVOKE_GET_ROOT_PATH_CMD = "Invoke-{modulename}GetConfigRootPath"
1313

1414
function Mock_Config{
1515
param(
@@ -40,9 +40,9 @@ function Mock_Config{
4040
$moduleName = $MODULE_NAME
4141
}
4242

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

4545
# Mock invoke call
4646
MockCallToString $invokefunction -OutString $fullpath
4747

48-
}
48+
}

Test/include/invokeCommand.mock.ps1

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,32 @@ $testRootPath = $MODULE_ROOT_PATH | Join-Path -ChildPath 'Test'
1515
$MOCK_PATH = $testRootPath | Join-Path -ChildPath 'private' -AdditionalChildPath 'mocks'
1616

1717
$MODULE_INVOKATION_TAG = "$($MODULE_NAME)Module"
18+
$MODULE_INVOKATION_TEST_TAG = "$($MODULE_NAME)TestModule"
1819
$MODULE_INVOKATION_TAG_MOCK = "$($MODULE_INVOKATION_TAG)_Mock"
1920

20-
$TraceInvokeMock = $testRootPath | Join-Path -ChildPath "traceInvoke.log"
21+
$TraceInvokeFilePathCommand = "Get-$($MODULE_NAME)TraceInvokeFilePath"
22+
23+
function Invoke-ModuleNameGetTraceInvokeFilePath{
24+
[CmdletBinding()]
25+
param()
26+
27+
$filePath = $testRootPath | Join-Path -ChildPath "traceInvoke.log"
28+
29+
return $filePath
30+
}
31+
Copy-Item -path Function:Invoke-ModuleNameGetTraceInvokeFilePath -Destination Function:"Invoke-$($MODULE_NAME)GetTraceInvokeFilePath"
32+
Export-ModuleMember -Function "Invoke-$($MODULE_NAME)GetTraceInvokeFilePath"
33+
InvokeHelper\Set-InvokeCommandAlias -Alias $TraceInvokeFilePathCommand -Command "Invoke-$($MODULE_NAME)GetTraceInvokeFilePath" -Tag $MODULE_INVOKATION_TEST_TAG
2134

2235
function Trace-InvokeCommandAlias{
2336
[CmdletBinding()]
2437
param(
2538
[Parameter(Mandatory,Position=0)][string]$Alias
2639
)
2740

28-
$filePath = $TraceInvokeMock
41+
$filePath = Invoke-MyCommand -Command $TraceInvokeFilePathCommand
2942

30-
if(! $filePath){ return }
31-
32-
# if(! (Test-Path $filePath)) {return}
43+
if(! (Test-Path $filePath)) {return}
3344

3445
$content = Get-Content $filePath
3546

@@ -292,4 +303,4 @@ function Assert-MockFileNotfound{
292303
Wait-Debugger
293304
throw "File not found or wrong case name. Expected[ $filename ] - Found[$( $file.name )]"
294305
}
295-
}
306+
}

Test/include/transcriptHelp.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ function Export-MyTranscript {
3232
[CmdletBinding()]
3333
param (
3434
[Parameter(Mandatory, Position = 0)]
35-
[array]$transcriptContent
35+
[object[]]$transcriptContent
3636
)
3737

3838
$i = 0..($transcriptContent.Count - 1) | Where-Object { $transcriptContent[$_] -eq "**********************" }
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,22 @@
66
# - Before all tests
77
# - After all tests
88

9-
function Run_BeforeAll{
10-
Write-Verbose "Run_BeforeAll"
11-
}
9+
# function Run_BeforeAll{
10+
# Write-Verbose "Run_BeforeAll"
11+
# }
1212

13-
function Run_AfterAll{
14-
Write-Verbose "Run_AfterAll"
15-
}
13+
# function Run_AfterAll{
14+
# Write-Verbose "Run_AfterAll"
15+
# }
1616

1717
function Run_BeforeEach{
1818
Write-Verbose "Run_BeforeEach"
1919

20-
Reset_Test_Mock
20+
Reset_Test_Mock
2121
}
2222

23-
function Run_AfterEach{
24-
Write-Verbose "Run_AfterEach"
25-
}
23+
# function Run_AfterEach{
24+
# Write-Verbose "Run_AfterEach"
25+
# }
2626

2727
Export-ModuleMember -Function Run_*

0 commit comments

Comments
 (0)