Skip to content

Commit 2a6e6a4

Browse files
committed
Added test to confirm that shell completion files are not generated on Windows
1 parent d64a3e4 commit 2a6e6a4

File tree

1 file changed

+24
-6
lines changed

1 file changed

+24
-6
lines changed

cmd/root_test.go

+24-6
Original file line numberDiff line numberDiff line change
@@ -812,18 +812,36 @@ func TestExecute_Completion(t *testing.T) {
812812
Execute()
813813

814814
bash := filepath.Join(os.Getenv("HOME"), ".bash_completion")
815-
if !file.IsFile(bash) {
816-
t.Errorf("not generate %s", bash)
815+
if runtime.GOOS == "windows" {
816+
if file.IsFile(bash) {
817+
t.Errorf("generate %s, however shell completion file is not generated on Windows", bash)
818+
}
819+
} else {
820+
if !file.IsFile(bash) {
821+
t.Errorf("failed to generate %s", bash)
822+
}
817823
}
818824

819825
fish := filepath.Join(os.Getenv("HOME"), ".config", "fish", "completions", cmdinfo.Name+".fish")
820-
if !file.IsFile(fish) {
821-
t.Errorf("not generate %s", fish)
826+
if runtime.GOOS == "windows" {
827+
if file.IsFile(fish) {
828+
t.Errorf("generate %s, however shell completion file is not generated on Windows", fish)
829+
}
830+
} else {
831+
if !file.IsFile(fish) {
832+
t.Errorf("failed to generate %s", fish)
833+
}
822834
}
823835

824836
zsh := filepath.Join(os.Getenv("HOME"), ".zsh", "completion", "_"+cmdinfo.Name)
825-
if !file.IsFile(zsh) {
826-
t.Errorf("not generate %s", zsh)
837+
if runtime.GOOS == "windows" {
838+
if file.IsFile(zsh) {
839+
t.Errorf("generate %s, however shell completion file is not generated on Windows", zsh)
840+
}
841+
} else {
842+
if !file.IsFile(zsh) {
843+
t.Errorf("failed to generate %s", zsh)
844+
}
827845
}
828846
})
829847
}

0 commit comments

Comments
 (0)