🪲 [Test]: Add test for removing all contexts#98
Closed
Marius Storhaug (MariusStorhaug) wants to merge 1 commit into
Closed
🪲 [Test]: Add test for removing all contexts#98Marius Storhaug (MariusStorhaug) wants to merge 1 commit into
Marius Storhaug (MariusStorhaug) wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
Adds a Pester test to verify that piping Get-Context into Remove-Context clears all contexts in a given vault.
- Introduces setup for multiple contexts in
VaultA - Asserts pre-removal state and exercises the removal pipeline
- Verifies that no contexts remain after running
Remove-Context
Comments suppressed due to low confidence (1)
tests/Context.Tests.ps1:239
- The test description mentions removing contexts specifically from VaultA, but the pipeline does not filter by vault. Consider updating the description or specifying the vault in the pipeline to align the test behavior with its title.
It 'Get-Context | Remove-Context - Should remove all contexts from VaultA' {
| $contextsBefore | Should -Not -BeNullOrEmpty | ||
| $contextsBefore.Count | Should -BeGreaterThan 0 | ||
|
|
||
| { Get-Context | Remove-Context } | Should -Not -Throw |
There was a problem hiding this comment.
The removal pipeline does not specify -Vault 'VaultA', so it may remove contexts from other vaults or miss targeting VaultA. Change it to Get-Context -Vault 'VaultA' | Remove-Context to scope the operation correctly.
Suggested change
| { Get-Context | Remove-Context } | Should -Not -Throw | |
| { Get-Context -Vault 'VaultA' | Remove-Context -Vault 'VaultA' } | Should -Not -Throw |
| { Get-Context | Remove-Context } | Should -Not -Throw | ||
|
|
||
| # Verify all contexts are removed | ||
| $contextsAfter = Get-Context |
There was a problem hiding this comment.
The post-removal assertion runs Get-Context without a vault filter. To verify that VaultA is emptied, use Get-Context -Vault 'VaultA' | Should -BeNullOrEmpty.
Suggested change
| $contextsAfter = Get-Context | |
| $contextsAfter = Get-Context -Vault 'VaultA' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Type of change
Checklist