MCPcopy Create free account
hub / github.com/Azure/ARO-HCP / TestUnixShellName

Function TestUnixShellName

tooling/hcpctl/pkg/shell/shell_test.go:206–248  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

204}
205
206func TestUnixShellName(t *testing.T) {
207 testCases := []struct {
208 name string
209 executable string
210 expected string
211 }{
212 {
213 name: "returns basename of executable for full path",
214 executable: "/bin/bash",
215 expected: "bash",
216 },
217 {
218 name: "returns basename for zsh",
219 executable: "/usr/bin/zsh",
220 expected: "zsh",
221 },
222 {
223 name: "returns basename for sh",
224 executable: "/bin/sh",
225 expected: "sh",
226 },
227 {
228 name: "returns executable name when no path",
229 executable: "bash",
230 expected: "bash",
231 },
232 {
233 name: "handles complex paths",
234 executable: "/usr/local/bin/fish",
235 expected: "fish",
236 },
237 }
238
239 for _, tc := range testCases {
240 t.Run(tc.name, func(t *testing.T) {
241 shell := NewUnixShell(tc.executable)
242 result := shell.Name()
243 if result != tc.expected {
244 t.Errorf("Expected %s, got %s", tc.expected, result)
245 }
246 })
247 }
248}

Callers

nothing calls this directly

Calls 3

NameMethod · 0.95
NewUnixShellFunction · 0.85
RunMethod · 0.65

Tested by

no test coverage detected