2020-09-15 04:44:53 -07:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestWriteCurrentShell(t *testing.T) {
|
|
|
|
expected := "zsh"
|
|
|
|
env := new(MockedEnvironment)
|
2020-09-24 10:11:56 -07:00
|
|
|
env.On("getShellName", nil).Return(expected, nil)
|
2020-09-15 04:44:53 -07:00
|
|
|
s := &shell{
|
2021-11-26 01:37:33 -08:00
|
|
|
env: env,
|
2020-09-15 04:44:53 -07:00
|
|
|
}
|
2020-09-20 10:13:37 -07:00
|
|
|
assert.Equal(t, expected, s.string())
|
|
|
|
}
|
2021-09-17 12:48:00 -07:00
|
|
|
|
|
|
|
func TestUseMappedShellNames(t *testing.T) {
|
|
|
|
cases := []struct {
|
|
|
|
Shell string
|
|
|
|
Expected string
|
|
|
|
}{
|
|
|
|
{Shell: "zsh", Expected: "zsh"},
|
|
|
|
{Shell: "pwsh", Expected: "PS"},
|
|
|
|
{Shell: "PWSH", Expected: "PS"},
|
|
|
|
}
|
|
|
|
for _, tc := range cases {
|
|
|
|
env := new(MockedEnvironment)
|
|
|
|
env.On("getShellName", nil).Return(tc.Expected, nil)
|
|
|
|
s := &shell{
|
|
|
|
env: env,
|
2021-11-26 01:37:33 -08:00
|
|
|
props: map[Property]interface{}{
|
|
|
|
MappedShellNames: map[string]string{"pwsh": "PS"},
|
2021-09-17 12:48:00 -07:00
|
|
|
},
|
|
|
|
}
|
|
|
|
got := s.string()
|
|
|
|
assert.Equal(t, tc.Expected, got)
|
|
|
|
}
|
|
|
|
}
|