Skip to content

Commit

Permalink
(tests) Add missing command to tab expansion tests
Browse files Browse the repository at this point in the history
Following on from some other work that was completed in this file, the
expeccted tab expansions for the cache, feature, config, source,
apikey, push, pack, new, uninstall, and list comands have been added.
  • Loading branch information
gep13 committed May 22, 2024
1 parent 75fd944 commit a741814
Showing 1 changed file with 162 additions and 0 deletions.
162 changes: 162 additions & 0 deletions tests/pester-tests/chocolateyProfile.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,168 @@ Describe "Chocolatey Profile" -Tag Chocolatey, Profile, Environment {
$Completions | Should -Contain "--include-configured-sources" -Because $becauseCompletions
}

It "Should list completions for cache" {
$Command = "choco cache "
$Completions = (TabExpansion2 -inputScript $Command -cursorColumn $Command.Length).CompletionMatches.CompletionText

$becauseCompletions = ($Completions -Join ", ")

$Completions[0] | Should -Be "list" -Because $becauseCompletions
$Completions[1] | Should -Be "remove" -Because $becauseCompletions
$Completions[2] | Should -Be "-?" -Because $becauseCompletions
$Completions | Should -Contain "--expired" -Because $becauseCompletions
}

It "Should list completions for feature" {
$Command = "choco feature "
$Completions = (TabExpansion2 -inputScript $Command -cursorColumn $Command.Length).CompletionMatches.CompletionText

$becauseCompletions = ($Completions -Join ", ")

$Completions[0] | Should -Be "list" -Because $becauseCompletions
$Completions[1] | Should -Be "get" -Because $becauseCompletions
$Completions[2] | Should -Be "disable" -Because $becauseCompletions
$Completions[3] | Should -Be "enable" -Because $becauseCompletions
$Completions[4] | Should -Be "-?" -Because $becauseCompletions
$Completions | Should -Contain "--name=''" -Because $becauseCompletions
}

It "Should list completions for config" {
$Command = "choco config "
$Completions = (TabExpansion2 -inputScript $Command -cursorColumn $Command.Length).CompletionMatches.CompletionText

$becauseCompletions = ($Completions -Join ", ")

$Completions[0] | Should -Be "list" -Because $becauseCompletions
$Completions[1] | Should -Be "get" -Because $becauseCompletions
$Completions[2] | Should -Be "set" -Because $becauseCompletions
$Completions[3] | Should -Be "unset" -Because $becauseCompletions
$Completions[4] | Should -Be "-?" -Because $becauseCompletions
$Completions | Should -Contain "--name=''" -Because $becauseCompletions
$Completions | Should -Contain "--value=''" -Because $becauseCompletions
}

It "Should list completions for source" {
$Command = "choco source "
$Completions = (TabExpansion2 -inputScript $Command -cursorColumn $Command.Length).CompletionMatches.CompletionText

$becauseCompletions = ($Completions -Join ", ")

$Completions[0] | Should -Be "list" -Because $becauseCompletions
$Completions[1] | Should -Be "add" -Because $becauseCompletions
$Completions[2] | Should -Be "remove" -Because $becauseCompletions
$Completions[3] | Should -Be "disable" -Because $becauseCompletions
$Completions[4] | Should -Be "enable" -Because $becauseCompletions
$Completions | Should -Contain "-?" -Because $becauseCompletions
$Completions | Should -Contain "--name=''" -Because $becauseCompletions
$Completions | Should -Contain "--source=''" -Because $becauseCompletions
$Completions | Should -Contain "--user=''" -Because $becauseCompletions
$Completions | Should -Contain "--password=''" -Because $becauseCompletions
$Completions | Should -Contain "--priority=''" -Because $becauseCompletions
$Completions | Should -Contain "--bypass-proxy" -Because $becauseCompletions
$Completions | Should -Contain "--allow-self-service" -Because $becauseCompletions
}

It "Should list completions for apikey" {
$Command = "choco apikey "
$Completions = (TabExpansion2 -inputScript $Command -cursorColumn $Command.Length).CompletionMatches.CompletionText

$becauseCompletions = ($Completions -Join ", ")

$Completions | Should -Contain "--source=''" -Because $becauseCompletions
$Completions | Should -Contain "--api-key=''" -Because $becauseCompletions
$Completions | Should -Contain "--remove" -Because $becauseCompletions
}

It "Should list completions for push" {
$Command = "choco push "
$Completions = (TabExpansion2 -inputScript $Command -cursorColumn $Command.Length).CompletionMatches.CompletionText

$becauseCompletions = ($Completions -Join ", ")

$Completions | Should -Contain "--source=''" -Because $becauseCompletions
$Completions | Should -Contain "--api-key=''" -Because $becauseCompletions
$Completions | Should -Contain "--timeout=''" -Because $becauseCompletions
}

It "Should list completions for pack" {
$Command = "choco pack "
$Completions = (TabExpansion2 -inputScript $Command -cursorColumn $Command.Length).CompletionMatches.CompletionText

$becauseCompletions = ($Completions -Join ", ")

$Completions | Should -Contain "--version=''" -Because $becauseCompletions
$Completions | Should -Contain "--output-directory=''" -Because $becauseCompletions
}

It "Should list completions for new" {
$Command = "choco new "
$Completions = (TabExpansion2 -inputScript $Command -cursorColumn $Command.Length).CompletionMatches.CompletionText

$becauseCompletions = ($Completions -Join ", ")

$Completions | Should -Contain "--template-name=''" -Because $becauseCompletions
$Completions | Should -Contain "--output-directory=''" -Because $becauseCompletions
$Completions | Should -Contain "--automaticpackage" -Because $becauseCompletions
$Completions | Should -Contain "--version=''" -Because $becauseCompletions
$Completions | Should -Contain "--maintainer=''" -Because $becauseCompletions
$Completions | Should -Contain "packageversion=''" -Because $becauseCompletions
$Completions | Should -Contain "maintainername=''" -Because $becauseCompletions
$Completions | Should -Contain "maintainerrepo=''" -Because $becauseCompletions
$Completions | Should -Contain "installertype=''" -Because $becauseCompletions
$Completions | Should -Contain "url=''" -Because $becauseCompletions
$Completions | Should -Contain "url64=''" -Because $becauseCompletions
$Completions | Should -Contain "silentargs=''" -Because $becauseCompletions
$Completions | Should -Contain "--use-built-in-template" -Because $becauseCompletions
}

It "Should list completions for uninstall" {
$Command = "choco uninstall "
$Completions = (TabExpansion2 -inputScript $Command -cursorColumn $Command.Length).CompletionMatches.CompletionText

$becauseCompletions = ($Completions -Join ", ")

$Completions | Should -Contain "-y" -Because $becauseCompletions
$Completions | Should -Contain "-whatif" -Because $becauseCompletions
$Completions | Should -Contain "--force-dependencies" -Because $becauseCompletions
$Completions | Should -Contain "--remove-dependencies" -Because $becauseCompletions
$Completions | Should -Contain "--all-versions" -Because $becauseCompletions
$Completions | Should -Contain "--source='windowsfeatures'" -Because $becauseCompletions
$Completions | Should -Contain "--version=''" -Because $becauseCompletions
$Completions | Should -Contain "--uninstall-arguments=''" -Because $becauseCompletions
$Completions | Should -Contain "--override-arguments" -Because $becauseCompletions
$Completions | Should -Contain "--not-silent" -Because $becauseCompletions
$Completions | Should -Contain "--params=''" -Because $becauseCompletions
$Completions | Should -Contain "--package-parameters=''" -Because $becauseCompletions
$Completions | Should -Contain "--exit-when-reboot-detected" -Because $becauseCompletions
$Completions | Should -Contain "--ignore-detected-reboot" -Because $becauseCompletions
$Completions | Should -Contain "--use-package-exit-codes" -Because $becauseCompletions
$Completions | Should -Contain "--ignore-package-exit-codes" -Because $becauseCompletions
$Completions | Should -Contain "--skip-automation-scripts" -Because $becauseCompletions
$Completions | Should -Contain "--use-autouninstaller" -Because $becauseCompletions
$Completions | Should -Contain "--skip-autouninstaller" -Because $becauseCompletions
$Completions | Should -Contain "--fail-on-autouninstaller" -Because $becauseCompletions
$Completions | Should -Contain "--ignore-autouninstaller-failure" -Because $becauseCompletions
$Completions | Should -Contain "--stop-on-first-package-failure" -Because $becauseCompletions
}

It "Should list completions for list" {
$Command = "choco list "
$Completions = (TabExpansion2 -inputScript $Command -cursorColumn $Command.Length).CompletionMatches.CompletionText

$becauseCompletions = ($Completions -Join ", ")

$Completions | Should -Contain "--id-only" -Because $becauseCompletions
$Completions | Should -Contain "--pre" -Because $becauseCompletions
$Completions | Should -Contain "--exact" -Because $becauseCompletions
$Completions | Should -Contain "--by-id-only" -Because $becauseCompletions
$Completions | Should -Contain "--id-starts-with" -Because $becauseCompletions
$Completions | Should -Contain "--detailed" -Because $becauseCompletions
$Completions | Should -Contain "--prerelease" -Because $becauseCompletions
$Completions | Should -Contain "--include-programs" -Because $becauseCompletions
$Completions | Should -Contain "--source=''" -Because $becauseCompletions
$Completions | Should -Contain "--page=''" -Because $becauseCompletions
$Completions | Should -Contain "--page-size=''" -Because $becauseCompletions
}
}
}

0 comments on commit a741814

Please sign in to comment.