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
44 changes: 44 additions & 0 deletions tests/Context.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,40 @@ Describe 'Context' {
{ Get-Context -ID $null -Vault 'VaultA' } | Should -Not -Throw
Get-Context -ID $null -Vault 'VaultA' | Should -BeNullOrEmpty
}
It 'Get-Context -ID array - Should return only specified contexts in VaultA' {
$ids = @('TestID1', 'TestID2')
$results = Get-Context -ID $ids -Vault 'VaultA'
$results | Should -Not -BeNullOrEmpty
$results.Count | Should -Be 2
$results.ID | Should -Contain 'TestID1'
$results.ID | Should -Contain 'TestID2'
$results.ID | Should -Not -Contain 'TestID3'
}
It 'Get-Context -ID single - Should not have output leakage (returns only one context)' {
$id = 'TestID1'
$results = Get-Context -ID $id -Vault 'VaultA'
$results | Should -Not -BeNullOrEmpty
$results.Count | Should -Be 1
$results.ID | Should -Be $id
}
It 'Get-Context -ID single (nonexistent) - Should not have output leakage (returns nothing)' {
$id = 'NonExistentContext'
$results = Get-Context -ID $id -Vault 'VaultA'
$results | Should -BeNullOrEmpty

Copilot AI Jun 8, 2025

Copy link

Choose a reason for hiding this comment

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

[nitpick] When validating that a collection is empty, consider using Should -BeEmpty for clarity and specificity rather than Should -BeNullOrEmpty.

Suggested change
$results | Should -BeNullOrEmpty
$results | Should -BeEmpty

Copilot uses AI. Check for mistakes.
}
It 'Get-Context -ID array with one valid and one invalid - Should not have output leakage (returns only valid)' {
$ids = @('TestID1', 'NonExistentContext')
$results = Get-Context -ID $ids -Vault 'VaultA'
$results | Should -Not -BeNullOrEmpty
$results.Count | Should -Be 1
$results.ID | Should -Be 'TestID1'
}
It 'Get-Context -ID with whitespace or null - Should not have output leakage (returns nothing)' {
$results = Get-Context -ID ' ' -Vault 'VaultA'
$results | Should -BeNullOrEmpty
Comment on lines +210 to +212

Copilot AI Jun 8, 2025

Copy link

Choose a reason for hiding this comment

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

[nitpick] This test covers both whitespace and $null IDs in one block, which may hide failures; consider splitting into separate tests for whitespace-only and null inputs for clearer failure isolation.

Suggested change
It 'Get-Context -ID with whitespace or null - Should not have output leakage (returns nothing)' {
$results = Get-Context -ID ' ' -Vault 'VaultA'
$results | Should -BeNullOrEmpty
It 'Get-Context -ID with whitespace - Should not have output leakage (returns nothing)' {
$results = Get-Context -ID ' ' -Vault 'VaultA'
$results | Should -BeNullOrEmpty
}
It 'Get-Context -ID with null - Should not have output leakage (returns nothing)' {

Copilot uses AI. Check for mistakes.
$results = Get-Context -ID $null -Vault 'VaultA'
$results | Should -BeNullOrEmpty
}
}

Context 'Remove-Context' {
Expand Down Expand Up @@ -304,5 +338,15 @@ Describe 'Context' {
$result = Get-ContextInfo -ID 'NonExistentContext' -Vault 'VaultA'
$result | Should -BeNullOrEmpty
}

It 'Should return only specified contexts for multiple IDs in VaultA' {
$ids = @('TestID1', 'TestID2')
$results = Get-ContextInfo -ID $ids -Vault 'VaultA'
$results | Should -Not -BeNullOrEmpty
$results.Count | Should -Be 2
$results.ID | Should -Contain 'TestID1'
$results.ID | Should -Contain 'TestID2'
$results.ID | Should -Not -Contain 'TestID3'
}
}
}
Loading