Skip to content

🪲 [Test]: Add test for removing all contexts#98

Closed
Marius Storhaug (MariusStorhaug) wants to merge 1 commit into
mainfrom
removeall
Closed

🪲 [Test]: Add test for removing all contexts#98
Marius Storhaug (MariusStorhaug) wants to merge 1 commit into
mainfrom
removeall

Conversation

@MariusStorhaug

Copy link
Copy Markdown
Member

Description

Type of change

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

Checklist

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas

Copilot AI review requested due to automatic review settings July 14, 2025 13:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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' {

Comment thread tests/Context.Tests.ps1
$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.
Comment thread tests/Context.Tests.ps1
{ Get-Context | Remove-Context } | Should -Not -Throw

# 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants