tests/functions/configuration/validations/timespan.Tests.ps1
|
Describe "timespan config validation" -Tag "CI", "Config", "Unit" { BeforeAll { $script:fullName = 'PSFTests.Validation.timespan' Set-PSFConfig -FullName $script:fullName -Value ([timespan]::Zero) -Validation 'timespan' -Initialize -AllowDelete -EnableException 3>$null } AfterAll { Remove-PSFConfig -FullName $script:fullName -Confirm:$false 3>$null } It "accepts values that are already valid" { $value = [timespan]::FromMinutes(5) { Set-PSFConfig -FullName $script:fullName -Value $value -EnableException 3>$null } | Should -Not -Throw Get-PSFConfigValue -FullName $script:fullName | Should -Be $value } It "accepts values that require conversion" { { Set-PSFConfig -FullName $script:fullName -Value '00:10:00' -EnableException 3>$null } | Should -Not -Throw Get-PSFConfigValue -FullName $script:fullName | Should -Be ([timespan]::FromMinutes(10)) } It "rejects invalid values" { { Set-PSFConfig -FullName $script:fullName -Value 'not-a-timespan' -EnableException 3>$null } | Should -Throw } } |