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

Function TestDetectShellPrioritizesVersionVariable

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

Source from the content-addressed store, hash-verified

148}
149
150func TestDetectShellPrioritizesVersionVariable(t *testing.T) {
151 // Save original environment
152 originalShell := os.Getenv("SHELL")
153 originalBashVersion := os.Getenv("BASH_VERSION")
154 originalZshVersion := os.Getenv("ZSH_VERSION")
155
156 // Restore environment after test
157 defer func() {
158 os.Setenv("SHELL", originalShell)
159 os.Setenv("BASH_VERSION", originalBashVersion)
160 os.Setenv("ZSH_VERSION", originalZshVersion)
161 }()
162
163 // Set SHELL to bash but ZSH_VERSION is set (running zsh inside bash)
164 os.Setenv("SHELL", "/bin/bash")
165 os.Setenv("ZSH_VERSION", "5.8")
166 os.Unsetenv("BASH_VERSION")
167
168 detected := DetectShell()
169
170 // Should prioritize ZSH_VERSION over SHELL
171 assert.Equal(t, ShellZsh, detected)
172}
173
174func TestShellTypeString(t *testing.T) {
175 tests := []struct {

Callers

nothing calls this directly

Calls 3

DetectShellFunction · 0.85
GetenvMethod · 0.80
SetenvMethod · 0.80

Tested by

no test coverage detected