diff --git a/tests/Store/03_Get-CredentialStore.Tests.ps1 b/src/Store/Get-CredentialStore.Tests.ps1 similarity index 75% rename from tests/Store/03_Get-CredentialStore.Tests.ps1 rename to src/Store/Get-CredentialStore.Tests.ps1 index 0bf63aa..4398a42 100644 --- a/tests/Store/03_Get-CredentialStore.Tests.ps1 +++ b/src/Store/Get-CredentialStore.Tests.ps1 @@ -1,4 +1,17 @@ -$RepoRoot = (Get-Item -Path (Get-GitDirectory) -Force).Parent | Select-Object -ExpandProperty 'FullName' +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 + } + + $RepoRoot = (Get-Item -Path (Get-GitDirectory) -Force).Parent | Select-Object -ExpandProperty 'FullName' +} Describe "Get-CredentialStore" { Context "Basic logic tests" { diff --git a/tests/Store/02_New-CredentialStore.Tests.ps1 b/src/Store/New-CredentialStore.Tests.ps1 similarity index 75% rename from tests/Store/02_New-CredentialStore.Tests.ps1 rename to src/Store/New-CredentialStore.Tests.ps1 index ec58d99..4a32cf4 100644 --- a/tests/Store/02_New-CredentialStore.Tests.ps1 +++ b/src/Store/New-CredentialStore.Tests.ps1 @@ -1,23 +1,35 @@ -# Backup existing credential stores -$VerbosePreference = "Continue" -Write-Verbose "Backup private Credential Store..." -$CSPath = Get-DefaultCredentialStorePath -$BackupFile = "{0}.back" -f $CSPath -If (Test-Path -Path $CSPath) { - Move-Item -Path $CSPath -Destination $BackupFile +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 + } + # Backup existing credential stores + $VerbosePreference = "Continue" + Write-Verbose "Backup private Credential Store..." + $CSPath = Get-DefaultCredentialStorePath + $BackupFile = "{0}.back" -f $CSPath + if (Test-Path -Path $CSPath) { + Move-Item -Path $CSPath -Destination $BackupFile + } + Write-Verbose "Backup shared CredentialStore..." + $CSShared = Get-DefaultCredentialStorePath -Shared + $BackupSharedFile = "{0}.back" -f $CSShared + if (Test-Path -Path $CSShared) { + Move-Item -Path $CSShared -Destination $BackupSharedFile + } + Write-Verbose "Remove old CredentialStore in Temp dir" + $CSTemp = Join-Path -Path (Get-TempDir) -ChildPath '/CredentialStore.json' + if (Test-Path -Path $CSTemp) { + Remove-Item -Path $CSTemp + } + $VerbosePreference = "SilentlyContinue" } -Write-Verbose "Backup shared CredentialStore..." -$CSShared = Get-DefaultCredentialStorePath -Shared -$BackupSharedFile = "{0}.back" -f $CSShared -If (Test-Path -Path $CSShared) { - Move-Item -Path $CSShared -Destination $BackupSharedFile -} -Write-Verbose "Remove old CredentialStore in Temp dir" -$CSTemp = Join-Path -Path (Get-TempDir) -ChildPath '/CredentialStore.json' -If (Test-Path -Path $CSTemp) { - Remove-Item -Path $CSTemp -} -$VerbosePreference = "SilentlyContinue" Describe "New-CredentialStore" { Context "Private CS tests" { diff --git a/tests/Store/02_Test-CredentialStore.Tests.ps1 b/src/Store/Test-CredentialStore.Tests.ps1 similarity index 76% rename from tests/Store/02_Test-CredentialStore.Tests.ps1 rename to src/Store/Test-CredentialStore.Tests.ps1 index 6cdeca9..33733e0 100644 --- a/tests/Store/02_Test-CredentialStore.Tests.ps1 +++ b/src/Store/Test-CredentialStore.Tests.ps1 @@ -1,4 +1,17 @@ -$RepoRoot = (Get-Item -Path (Get-GitDirectory) -Force).Parent | Select-Object -ExpandProperty 'FullName' +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 + } + + $RepoRoot = (Get-Item -Path (Get-GitDirectory) -Force).Parent | Select-Object -ExpandProperty 'FullName' +} Describe "Test-CredentialStore" { Context "Basic logic tests" {