Skip to content

Commit

Permalink
chore: Expand and tidy up completion test
Browse files Browse the repository at this point in the history
  • Loading branch information
twpayne committed Nov 4, 2024
1 parent 5ee2c70 commit 1641748
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 19 deletions.
2 changes: 1 addition & 1 deletion internal/chezmoi/refreshexternals.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var (
"never": RefreshExternalsNever,
}

RefreshExternalsFlagCompletionFunc = FlagCompletionFunc(chezmoimaps.Keys(refreshExternalsWellKnownStrings))
RefreshExternalsFlagCompletionFunc = FlagCompletionFunc(chezmoimaps.SortedKeys(refreshExternalsWellKnownStrings))
)

func (re *RefreshExternals) Set(s string) error {
Expand Down
61 changes: 43 additions & 18 deletions internal/cmd/testdata/scripts/completion.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -14,56 +14,68 @@ stdout 'Register-ArgumentCompleter'
exec chezmoi completion zsh
stdout '#compdef chezmoi'

# test that autoBool values are completed
# test that --color t values are completed
exec chezmoi __complete --color t
cmp stdout golden/auto-bool-t

# test that mode values are completed
# test that --mode values are completed
exec chezmoi __complete --mode ''
cmp stdout golden/mode

# test that --use-builtin flags are completed
exec chezmoi __complete --use-builtin
cmp stdout golden/use-builtin-flags

# test that add --secrets values are completed
exec chezmoi __complete add --secrets=
cmp stdout golden/secrets

# test that apply --exclude values are completed
exec chezmoi __complete apply --exclude=
cmp stdout golden/entry-type-set

# test that apply --refresh-externals flags are completed
exec chezmoi __complete apply --refresh-externals=
cmp stdout golden/refresh-externals

# test that entry type set values are completed
exec chezmoi __complete apply --include ''
exec chezmoi __complete apply --include=
cmp stdout golden/entry-type-set

# test that "archive --format" values are completed
exec chezmoi __complete archive --format ''
# test that archive --format values are completed
exec chezmoi __complete archive --format=
cmp stdout golden/archive-format

# test that "data --format" values are completed
exec chezmoi __complete data --format ''
# test that data --format values are completed
exec chezmoi __complete data --format=
cmp stdout golden/output-format

# test that "dump --format" values are completed
exec chezmoi __complete dump --format ''
# test that dump --format values are completed
exec chezmoi __complete dump --format=
cmp stdout golden/output-format

# test that "dump-config --format" values are completed
exec chezmoi __complete dump-config --format ''
# test that dump-config --format values are completed
exec chezmoi __complete dump-config --format=
cmp stdout golden/output-format

# test that managed path style values are completed
exec chezmoi __complete managed --path-style ''
exec chezmoi __complete managed --path-style=
cmp stdout golden/path-style

# test that "state data --format" values are completed
exec chezmoi __complete state data --format ''
# test that state data --format values are completed
exec chezmoi __complete state data --format=
cmp stdout golden/output-format

# test that "state dump --format" values are completed
exec chezmoi __complete state dump --format ''
# test that state dump --format values are completed
exec chezmoi __complete state dump --format=
cmp stdout golden/output-format

# test that status path style values are completed
exec chezmoi __complete status --path-style ''
exec chezmoi __complete status --path-style=
cmp stdout golden/path-style

# test that unmanaged path style values are completed
exec chezmoi __complete unmanaged --path-style ''
exec chezmoi __complete unmanaged --path-style=
cmp stdout golden/unmanaged-path-style

-- golden/archive-format --
Expand Down Expand Up @@ -117,6 +129,19 @@ relative
source-absolute
source-relative
:4
-- golden/refresh-externals --
always
auto
never
:4
-- golden/secrets --
i
ignore
w
warning
e
error
:4
-- golden/unmanaged-path-style --
absolute
relative
Expand Down

0 comments on commit 1641748

Please sign in to comment.