1
0
mirror of https://github.com/docker/docs.git synced 2026-11-05 00:14:17 +03:00
Files
docs/commands/detectshell_test.go
Stefan Scherer d394cffe49 Auto-detect shell on Windows
Signed-off-by: Stefan Scherer <scherer_stefan@icloud.com>
2016-01-03 03:35:12 +01:00

30 lines
712 B
Go

package commands
import (
"os"
"testing"
"github.com/stretchr/testify/assert"
)
func TestDetectBash(t *testing.T) {
originalShell := os.Getenv("SHELL")
os.Setenv("SHELL", "/bin/bash")
defer os.Setenv("SHELL", originalShell)
shell, err := detectShell()
assert.Nil(t, err)
assert.Equal(t, "bash", shell)
}
func TestDetectFish(t *testing.T) {
originalShell := os.Getenv("SHELL")
os.Setenv("SHELL", "/bin/bash")
defer os.Setenv("SHELL", originalShell)
originalFishdir := os.Getenv("__fish_bin_dir")
os.Setenv("__fish_bin_dir", "/usr/local/Cellar/fish/2.2.0/bin")
defer os.Setenv("__fish_bin_dir", originalFishdir)
shell, err := detectShell()
assert.Nil(t, err)
assert.Equal(t, "fish", shell)
}