Skip to content

Commit

Permalink
🩹 [Patch]: Add more tests (100% CodeCoverage) (#9)
Browse files Browse the repository at this point in the history
## Description

- Add more tests

## Type of change

<!-- Use the check-boxes [x] on the options that are relevant. -->

- [ ] 📖 [Docs]
- [ ] 🪲 [Fix]
- [x] 🩹 [Patch]
- [ ] ⚠️ [Security fix]
- [ ] 🚀 [Feature]
- [ ] 🌟 [Breaking change]

## Checklist

<!-- Use the check-boxes [x] on the options that are relevant. -->

- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
  • Loading branch information
MariusStorhaug committed Mar 17, 2024
1 parent f5062f6 commit 6f68493
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
6 changes: 1 addition & 5 deletions src/Store/public/Get-StoreConfig.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,9 @@

$value = Get-StoreVariable -Name $Name

if ($null -eq $value) {
if (($null -eq $value) -and ((Get-SecretInfo -Vault $script:Store.SecretVaultName).Name -contains $Name)) {
$value = Get-Secret -Name $Name -AsPlainText -Vault $script:Store.SecretVaultName
}

if ($null -eq $value) {
throw "Configuration value not found: $Name"
}

$value
}
1 change: 1 addition & 0 deletions src/Store/public/Set-StoreConfig.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

# The value to set.
[Parameter(Mandatory)]
[AllowNull()]
[object] $Value
)

Expand Down
10 changes: 9 additions & 1 deletion tests/Store.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Write-Verbose (Get-Module -Name 'Store' -ListAvailable | Out-String) -Verbose
}
It 'The module should be importable' {
{ Import-Module -Name 'Store' } | Should -Not -Throw
{ Import-Module -Name 'Store' -Force -Verbose } | Should -Not -Throw
}
}
Context 'Initialize-Store' {
Expand All @@ -15,6 +15,9 @@
It 'Should be able to run' {
{ Initialize-Store -Name 'GitHub' } | Should -Not -Throw
}
It 'Should be able to run multiple times without erroring out' {
{ Initialize-Store -Name 'GitHub' } | Should -Not -Throw
}
}
Context 'Get-StoreConfig' {
It 'Should be available' {
Expand Down Expand Up @@ -57,5 +60,10 @@
$secret = Get-StoreConfig -Name 'Secret'
$secret | Should -Be 'Something'
}
It 'Should be able to remove a variable if set to $null' {
Set-StoreConfig -Name 'Something' -Value $null
$something = Get-StoreConfig -Name 'Something'
$something | Should -BeNullOrEmpty
}
}
}

0 comments on commit 6f68493

Please sign in to comment.