forked from OCram85/PSCredentialStore
Migrates to Pester5+ tests (#59)
#### 📖 Summary - update Pester tests to Pester5+ compatiple layout - switch to dotnet base imaged - dotnet binary required for publishung powershell modules (Publish-Module) #### 📑 Test Plan > 💡 Select your test plan for the code changes. - [x] Tested via Drone.io pipeline - [ ] Custom test - [ ] No test plan ##### Details / Justification <!-- Add your test details or justification for missing tests here. --> #### 📚 Additional Notes <!-- A place for additional detail notes. --> Co-authored-by: OCram85 <marco.blessing@googlemail.com> Reviewed-on: OCram85/PSCredentialStore#59
This commit is contained in:
62
src/Private/Get-DefaultCredentialStorePath.Tests.ps1
Normal file
62
src/Private/Get-DefaultCredentialStorePath.Tests.ps1
Normal file
@ -0,0 +1,62 @@
|
||||
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 "Get-DefaultCredentialStorePath" {
|
||||
Context "Basic syntax test" {
|
||||
It "Test1: Should not throw" {
|
||||
{ Get-DefaultCredentialStorePath } | Should -Not -Throw
|
||||
}
|
||||
}
|
||||
|
||||
Context "Private Type" {
|
||||
It "Should return correct paths" {
|
||||
$Path = Get-DefaultCredentialStorePath
|
||||
#Write-Verbose -Message ('Delivered path is: {0}' -f $Path) -Verbose
|
||||
if ($Env:APPVEYOR) {
|
||||
$PathRef = Join-Path -Path $Env:APPDATA -ChildPath 'CredentialStore.json'
|
||||
$Path | Should -Be $PathRef
|
||||
}
|
||||
elseif ($ENV:TRAVIS) {
|
||||
if ($IsLinux) {
|
||||
$PathRef = Join-Path -Path $Env:HOME -ChildPath 'CredentialStore.json'
|
||||
$Path | Should -Be $PathRef
|
||||
}
|
||||
elseif ($IsMacOS) {
|
||||
$PathRef = Join-Path -Path $Env:HOME -ChildPath 'CredentialStore.json'
|
||||
$Path | Should -Be $PathRef
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Context "Shared Type" {
|
||||
It "Should return correct paths" {
|
||||
$Path = Get-DefaultCredentialStorePath -Shared
|
||||
#Write-Verbose -Message ('Delivered path is: {0}' -f $Path) -Verbose
|
||||
if ($Env:APPVEYOR) {
|
||||
$PathRef = Join-Path -Path $env:ProgramData -ChildPath 'PSCredentialStore/CredentialStore.json'
|
||||
$Path | Should -Be $PathRef
|
||||
}
|
||||
elseif ($ENV:TRAVIS) {
|
||||
if ($IsLinux) {
|
||||
$PathRef = Join-Path -Path '/var/opt' -ChildPath 'PSCredentialStore/CredentialStore.json'
|
||||
$Path | Should -Be $PathRef
|
||||
}
|
||||
elseif ($IsMacOS) {
|
||||
$PathRef = Join-Path -Path '/var/opt' -ChildPath 'PSCredentialStore/CredentialStore.json'
|
||||
$Path | Should -Be $PathRef
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user