forked from adamlaska/machine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshell_windows_test.go
More file actions
41 lines (30 loc) · 927 Bytes
/
shell_windows_test.go
File metadata and controls
41 lines (30 loc) · 927 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package shell
import (
"os"
"testing"
"github.com/stretchr/testify/assert"
)
func TestDetect(t *testing.T) {
defer func(shell string) { os.Setenv("SHELL", shell) }(os.Getenv("SHELL"))
os.Setenv("SHELL", "")
shell, err := Detect()
assert.Equal(t, "powershell", shell)
assert.NoError(t, err)
}
func TestGetNameAndItsPpidOfCurrent(t *testing.T) {
shell, shellppid, err := getNameAndItsPpid(os.Getpid())
assert.Equal(t, "shell.test.exe", shell)
assert.Equal(t, os.Getppid(), shellppid)
assert.NoError(t, err)
}
func TestGetNameAndItsPpidOfParent(t *testing.T) {
shell, _, err := getNameAndItsPpid(os.Getppid())
assert.Equal(t, "go.exe", shell)
assert.NoError(t, err)
}
func TestGetNameAndItsPpidOfGrandParent(t *testing.T) {
shell, shellppid, err := getNameAndItsPpid(os.Getppid())
shell, shellppid, err = getNameAndItsPpid(shellppid)
assert.Equal(t, "powershell.exe", shell)
assert.NoError(t, err)
}