Skip to content

Commit c8cc83c

Browse files
committed
feat(invokeCommand): add function to retrieve trace invoke file path
1 parent 18de122 commit c8cc83c

1 file changed

Lines changed: 17 additions & 6 deletions

File tree

‎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+
}

0 commit comments

Comments
 (0)