From 8808f1c70b8a86513ebab77858884160904bbab7 Mon Sep 17 00:00:00 2001 From: OCram85 Date: Tue, 28 Jun 2022 11:24:31 +0200 Subject: [PATCH] wip --- .../Item/New-CredentialStoreItem.Tests.ps1 | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) rename tests/Item/03_New-CredentialStoreItem.Tests.ps1 => src/Item/New-CredentialStoreItem.Tests.ps1 (89%) diff --git a/tests/Item/03_New-CredentialStoreItem.Tests.ps1 b/src/Item/New-CredentialStoreItem.Tests.ps1 similarity index 89% rename from tests/Item/03_New-CredentialStoreItem.Tests.ps1 rename to src/Item/New-CredentialStoreItem.Tests.ps1 index 56ce83b..166b831 100644 --- a/tests/Item/03_New-CredentialStoreItem.Tests.ps1 +++ b/src/Item/New-CredentialStoreItem.Tests.ps1 @@ -1,6 +1,19 @@ +BeforeAll { + $ManifestFile = (Get-Item -Path "./src/*.psd1").FullName + Import-Module $ManifestFile -Force + + $PrivateFunctions = (Get-ChildItem -Path "./src/Private/*.ps1" | Where-Object { + $_.BaseName -notmatch '.Tests' + } + ).FullName + foreach ( $func in $PrivateFunctions) { + . $func + } +} + Describe "New-CredentialStoreItem" { Context "Private Credential Store tests" { - It "Test1: Add entry to existing private store." { + It "Add entry to existing private store." { # Creat a fresh CredentialStore first New-CredentialStore -Force @@ -20,7 +33,7 @@ Describe "New-CredentialStoreItem" { } } Context "Test with new shared Credential Store" { - It "Test2: Create new RemoteHost entry" { + It "Create new RemoteHost entry" { # prepare test environment $tmpCS = Join-Path -Path (Get-TempDir) -ChildPath '/CredentialStore.json' New-CredentialStore -Shared -Path $tmpCS -Force @@ -48,7 +61,6 @@ Describe "New-CredentialStoreItem" { } } Context "Test optional parameter lookup" { - It "Test missing Credential" { function global:Get-Credential ([string]$Message) { $UserName = 'testuser' @@ -65,7 +77,7 @@ Describe "New-CredentialStoreItem" { } Context "General Exception handling" { - Mock Test-CredentialStore { return $false } + Mock Test-CredentialStore { return $false } -ModuleName 'PSCredentialStore' It "Missing CredentialStore should throw" { { New-CredentialStoreItem -Shared -Path 'C:\missingStore.json' -RemoteHost 'notrelevant' } | Should -Throw "Could not add anything" }