Increase code coverage (#22)
This commit is contained in:
@ -33,5 +33,15 @@ Describe "Get-CredentialStore" {
|
||||
|
||||
{Get-CredentialStore -Path $TestCredentialStore} | Should Not Throw
|
||||
}
|
||||
It "Test3: Not existing path should return false" {
|
||||
{ Get-CredentialStore -Path 'C:\foobar\CredentialStore.json' -Shared }| Should -Throw "Could not find the CredentialStore."
|
||||
}
|
||||
}
|
||||
Context "Testing invalid json data" {
|
||||
Mock Test-CredentialStore {return $true}
|
||||
Mock Get-Content {return '"foo":"bar",'}
|
||||
It "Should throw with invalid CredentialStore" {
|
||||
{ Get-Credentialstore -Path "C:\dummy.json"} | Should -Throw "Unknown CredentialStore format. Invalid JSON file."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -92,6 +92,12 @@ Describe "New-CredentialStore" {
|
||||
{New-CredentialStore -Path $pCS -Shared -Force} | Should Not Throw
|
||||
}
|
||||
}
|
||||
Context "Test exception handling" {
|
||||
Mock Out-File {throw "foobar exception"}
|
||||
It "JSON Converstion should fail and throw" {
|
||||
{ New-CredentialStore -Path "C:\dummy.json"} | Should -Throw
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Cleanup test stores and restore existing ones.
|
||||
|
@ -36,5 +36,14 @@ Describe "Test-CredentialStore" {
|
||||
$res | Should Be $False
|
||||
$WarningPreference = $oWarningPreference
|
||||
}
|
||||
It "Test4: Not existing path should return false" {
|
||||
Test-CredentialStore -Path 'C:\foobar\CredentialStore.json' | Should -Be $false
|
||||
}
|
||||
It "Test5: testing private CredentialStore path" {
|
||||
if (Test-Path -Path ("{0}\CredentialStore.json" -f $env:APPDATA) ) {
|
||||
Remove-Item -Path ("{0}\CredentialStore.json" -f $env:APPDATA)
|
||||
}
|
||||
Test-CredentialStore | Should -Be $false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user