1
0
mirror of https://github.com/docker/docs.git synced 2026-11-05 00:14:17 +03:00
Files
docs/commands/shell/shell_test.go
David Gageot 5ff7ab91fb Extract shell detection to its own package
Signed-off-by: David Gageot <david@gageot.net>
2016-01-04 15:58:30 +01:00

30 lines
699 B
Go

package shell
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 := Detect()
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 := Detect()
assert.Nil(t, err)
assert.Equal(t, "fish", shell)
}