Skip to content

Commit 0611d9f

Browse files
Add tests for Scope parameter in Install/Uninstall-AITool
Introduces tests to verify the Scope parameter handling for both Install-AITool and Uninstall-AITool, including validation of accepted values, parameter types, and default behaviors for CurrentUser and LocalMachine scopes.
1 parent fa07292 commit 0611d9f

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

Tests/aitools.Tests.ps1

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,60 @@ function Get-TestData {
203203
}
204204
}
205205

206+
Context 'Install-AITool Scope Parameter' {
207+
It 'Should accept CurrentUser scope' {
208+
# CurrentUser is the default, should work without issues
209+
$result = Install-AITool -Name Claude -Scope CurrentUser -SkipInitialization
210+
$result | Should -Not -BeNullOrEmpty
211+
$result.Result | Should -Be 'Success'
212+
}
213+
214+
It 'Should accept LocalMachine scope parameter' {
215+
# Verify the parameter is accepted (actual installation may require sudo)
216+
{ Get-Command Install-AITool | Should -Not -BeNullOrEmpty } | Should -Not -Throw
217+
$cmd = Get-Command Install-AITool
218+
$cmd.Parameters['Scope'] | Should -Not -BeNullOrEmpty
219+
$cmd.Parameters['Scope'].ParameterType.Name | Should -Be 'String'
220+
}
221+
222+
It 'Should have valid Scope parameter values' {
223+
$cmd = Get-Command Install-AITool
224+
$validateSet = $cmd.Parameters['Scope'].Attributes | Where-Object { $_ -is [System.Management.Automation.ValidateSetAttribute] }
225+
$validateSet.ValidValues | Should -Contain 'CurrentUser'
226+
$validateSet.ValidValues | Should -Contain 'LocalMachine'
227+
}
228+
229+
It 'Should handle LocalMachine scope for already-installed tool' {
230+
# Claude is already installed, so this tests the code path without needing sudo
231+
$result = Install-AITool -Name Claude -Scope LocalMachine -SkipInitialization
232+
$result | Should -Not -BeNullOrEmpty
233+
$result.Result | Should -Be 'Success'
234+
$result.Installer | Should -Be 'Already Installed'
235+
}
236+
}
237+
238+
Context 'Uninstall-AITool Scope Parameter' {
239+
It 'Should accept Scope parameter' {
240+
$cmd = Get-Command Uninstall-AITool
241+
$cmd.Parameters['Scope'] | Should -Not -BeNullOrEmpty
242+
$cmd.Parameters['Scope'].ParameterType.Name | Should -Be 'String'
243+
}
244+
245+
It 'Should have valid Scope parameter values' {
246+
$cmd = Get-Command Uninstall-AITool
247+
$validateSet = $cmd.Parameters['Scope'].Attributes | Where-Object { $_ -is [System.Management.Automation.ValidateSetAttribute] }
248+
$validateSet.ValidValues | Should -Contain 'CurrentUser'
249+
$validateSet.ValidValues | Should -Contain 'LocalMachine'
250+
}
251+
252+
It 'Should default to CurrentUser scope' {
253+
$cmd = Get-Command Uninstall-AITool
254+
$scopeParam = $cmd.Parameters['Scope']
255+
# Check that it has a default value
256+
$scopeParam.Attributes | Where-Object { $_ -is [System.Management.Automation.ParameterAttribute] } | Should -Not -BeNullOrEmpty
257+
}
258+
}
259+
206260
}
207261

208262
AfterAll {

0 commit comments

Comments
 (0)