fix scoping issue in test file

This commit is contained in:
OCram85 2018-03-21 11:40:13 +01:00
parent 82da4dc20a
commit 7ab662c860

View File

@ -79,15 +79,14 @@ Describe "New-CredentialStoreItem" {
return [PSCredential]::new($UserName, $Password) return [PSCredential]::new($UserName, $Password)
} }
}
It "Test missing Credential" { It "Test missing Credential" {
$tmpCS = 'C:\CredentialStore.json' $tmpCS = 'C:\CredentialStore.json'
New-CredentialStoreItem -Path $tmpCs -Shared -RemoteHost 'foobar3' New-CredentialStoreItem -Path $tmpCs -Shared -RemoteHost 'foobar3'
$writtenItem = Get-CredentialStoreItem -Path $tmpCS -Shared -RemoteHost 'foobar3' $writtenItem = Get-CredentialStoreItem -Path $tmpCS -Shared -RemoteHost 'foobar3'
$writtenItem.UserName | Should -Be "myUser" $writtenItem.UserName | Should -Be "myUser"
} }
} }
Context "General Exception handling" { Context "General Exception handling" {
Mock Test-CredentialStore {return $false} Mock Test-CredentialStore {return $false}
$UserName = 'myUser' $UserName = 'myUser'
$Password = ConvertTo-SecureString -String "mypasswd" -AsPlainText -Force $Password = ConvertTo-SecureString -String "mypasswd" -AsPlainText -Force
@ -98,4 +97,6 @@ Context "General Exception handling" {
It "Missing CredentialStore should throw" { It "Missing CredentialStore should throw" {
New-CredentialStoreItem -Path 'C:\missingStore.json' -RemoteHost 'notrelevant' | Should -Throw "Could not add anything" New-CredentialStoreItem -Path 'C:\missingStore.json' -RemoteHost 'notrelevant' | Should -Throw "Could not add anything"
} }
}
} }