MCPcopy Create free account
hub / github.com/github/gh-aw / TestDetectShellNoShellEnv

Function TestDetectShellNoShellEnv

pkg/cli/shell_completion_test.go:118–148  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

116}
117
118func TestDetectShellNoShellEnv(t *testing.T) {
119 // Save original environment
120 originalShell := os.Getenv("SHELL")
121 originalBashVersion := os.Getenv("BASH_VERSION")
122 originalZshVersion := os.Getenv("ZSH_VERSION")
123 originalFishVersion := os.Getenv("FISH_VERSION")
124
125 // Restore environment after test
126 defer func() {
127 os.Setenv("SHELL", originalShell)
128 os.Setenv("BASH_VERSION", originalBashVersion)
129 os.Setenv("ZSH_VERSION", originalZshVersion)
130 os.Setenv("FISH_VERSION", originalFishVersion)
131 }()
132
133 // Clear all shell environment variables
134 os.Unsetenv("SHELL")
135 os.Unsetenv("BASH_VERSION")
136 os.Unsetenv("ZSH_VERSION")
137 os.Unsetenv("FISH_VERSION")
138
139 detected := DetectShell()
140
141 // On Windows, should detect PowerShell
142 if runtime.GOOS == "windows" {
143 assert.Equal(t, ShellPowerShell, detected)
144 } else {
145 // On Unix-like systems, should be unknown
146 assert.Equal(t, ShellUnknown, detected)
147 }
148}
149
150func TestDetectShellPrioritizesVersionVariable(t *testing.T) {
151 // Save original environment

Callers

nothing calls this directly

Calls 3

DetectShellFunction · 0.85
GetenvMethod · 0.80
SetenvMethod · 0.80

Tested by

no test coverage detected