Added unit tests and renamed a parameter !deploy
This commit is contained in:
@@ -16,14 +16,15 @@ function Get-Chronometer
|
|||||||
$Path,
|
$Path,
|
||||||
|
|
||||||
# The script to start the scrupt or execute other commands
|
# The script to start the scrupt or execute other commands
|
||||||
|
[alias('Script','CommandScript')]
|
||||||
[scriptblock]
|
[scriptblock]
|
||||||
$CommandScript
|
$ScriptBlock
|
||||||
)
|
)
|
||||||
|
|
||||||
$breakPoint = @()
|
$breakPoint = @()
|
||||||
$fileMap = @{}
|
$fileMap = @{}
|
||||||
|
|
||||||
foreach($file in (Resolve-Path $Path))
|
foreach($file in (Resolve-Path $Path -ea 0))
|
||||||
{
|
{
|
||||||
$fileMap[$file.Path] = @( Get-Content -Path $file | %{[ScriptLine]@{text=$_;path=$file.path}})
|
$fileMap[$file.Path] = @( Get-Content -Path $file | %{[ScriptLine]@{text=$_;path=$file.path}})
|
||||||
|
|
||||||
@@ -32,7 +33,7 @@ function Get-Chronometer
|
|||||||
}
|
}
|
||||||
|
|
||||||
[ScriptProfiler]::Start()
|
[ScriptProfiler]::Start()
|
||||||
[void] $CommandScript.Invoke()
|
[void] $ScriptBlock.Invoke()
|
||||||
|
|
||||||
Remove-PSBreakpoint $breakpoint
|
Remove-PSBreakpoint $breakpoint
|
||||||
|
|
||||||
|
|||||||
31
Tests/Unit.Tests.ps1
Normal file
31
Tests/Unit.Tests.ps1
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
$projectRoot = Resolve-Path "$PSScriptRoot\.."
|
||||||
|
$moduleRoot = Split-Path (Resolve-Path "$projectRoot\*\*.psd1")
|
||||||
|
$moduleName = Split-Path $moduleRoot -Leaf
|
||||||
|
|
||||||
|
Import-Module (Join-Path $moduleRoot "$moduleName.psm1") -force
|
||||||
|
|
||||||
|
Describe "Basic unit tests" -Tags Build {
|
||||||
|
|
||||||
|
Context "Function: Get-Chronometer" {
|
||||||
|
it "Does not throw" {
|
||||||
|
{Get-Chronometer -Path $PSScriptRoot\..\ScratchFiles\example.ps1 -Script {"Test"} } | Should Not Throw
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
InModuleScope $moduleName {
|
||||||
|
Context "Class: ScriptLine" {
|
||||||
|
|
||||||
|
it "Creates an Object" {
|
||||||
|
{[ScriptLine]::New()} | Should Not Throw
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Context "Class: ScriptProfiler" {
|
||||||
|
|
||||||
|
it "Creates an Object" {
|
||||||
|
{[ScriptProfiler]::New()} | Should Not Throw
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user