Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions tests/Context.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,22 @@ Describe 'Context' {
{ 'john_doe' | Remove-Context -Vault 'VaultA' } | Should -Not -Throw
Get-Context -ID 'john_doe' -Vault 'VaultA' | Should -BeNullOrEmpty
}
It 'Get-Context | Remove-Context - Should remove all contexts from VaultA' {
# Setup: Create multiple contexts in VaultA
Set-Context -ID 'TestContext1' -Context @{ Data = 'Test1' } -Vault 'VaultA'
Set-Context -ID 'TestContext2' -Context @{ Data = 'Test2' } -Vault 'VaultA'
Set-Context -ID 'TestContext3' -Context @{ Data = 'Test3' } -Vault 'VaultA'

$contextsBefore = Get-Context -Vault 'VaultA'
$contextsBefore | Should -Not -BeNullOrEmpty
$contextsBefore.Count | Should -BeGreaterThan 0

{ Get-Context | Remove-Context } | Should -Not -Throw

Copilot AI Jul 14, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copilot uses AI. Check for mistakes.

# Verify all contexts are removed
$contextsAfter = Get-Context

Copilot AI Jul 14, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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'

Copilot uses AI. Check for mistakes.
$contextsAfter | Should -BeNullOrEmpty
}
}

Context 'Rename-Context' {
Expand Down
Loading