fix Format-Checklist bug and example.ps1 integration test script (#23)

version-bump
Chris Kuech 2019-07-26 12:15:06 -07:00 committed by GitHub
parent 7f675f361d
commit d5464fbae6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 2 deletions

View File

@ -2,6 +2,8 @@
$ErrorActionPreference = "Stop"
Import-Module "$PSScriptRoot\Requirements.psd1" -Force
$requirements = @(
@{
Name = "Resource 1"
@ -19,13 +21,13 @@ $requirements = @(
Name = "Resource 3"
Describe = "Resource 3 is present in the system"
Test = { $mySystem -contains 3 }
Set = { $mySystem.Add(3) | Out-Null; Start-Sleep 1 }
Set = { throw "This should not have been reached!"; Start-Sleep 1 }
},
@{
Name = "Resource 4"
Describe = "Resource 4 is present in the system"
Test = { $mySystem -contains 4 }
Set = { $mySystem.Add(4) | Out-Null; Start-Sleep 1 }
Set = { throw "This should not have been reached!"; Start-Sleep 1 }
},
@{
Name = "Resource 5"
@ -37,14 +39,20 @@ $requirements = @(
# demo using Format-Table
$mySystem = [System.Collections.ArrayList]::new()
$mySystem.Add(3) | Out-Null
$mySystem.Add(4) | Out-Null
$requirements | Invoke-Requirement | Format-Table
# demo using Format-Checklist
$mySystem = [System.Collections.ArrayList]::new()
$mySystem.Add(3) | Out-Null
$mySystem.Add(4) | Out-Null
$requirements | Invoke-Requirement | Format-Checklist
# demo using Format-CallStack
$mySystem = [System.Collections.ArrayList]::new()
$mySystem.Add(3) | Out-Null
$mySystem.Add(4) | Out-Null
$requirements | Invoke-Requirement | Format-CallStack
# demo using Format-Callstack with nested requirements

View File

@ -38,6 +38,18 @@ function Format-Checklist {
Write-Host $message -ForegroundColor $color -NoNewline
$lastDescription = $description
}
"Stop" {
switch ($result) {
$true {
$symbol = [char]8730
$color = "Green"
$message = "$timestamp [ $symbol ] $description"
Write-Host "`r$(' ' * $lastDescription.Length)" -NoNewline
Write-Host "`r$message" -ForegroundColor $color
$lastDescription = $description
}
}
}
}
}
"Validate" {