-
Notifications
You must be signed in to change notification settings - Fork 201
Expand file tree
/
Copy pathsysutil_test.go
More file actions
36 lines (30 loc) · 981 Bytes
/
sysutil_test.go
File metadata and controls
36 lines (30 loc) · 981 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
package sysutil_test
import (
"os"
"runtime"
"testing"
"github.com/gookit/goutil/dump"
"github.com/gookit/goutil/sysutil"
"github.com/gookit/goutil/testutil/assert"
)
func TestSysUtil_basic(t *testing.T) {
assert.NotEmpty(t, sysutil.BinDir())
assert.NotEmpty(t, sysutil.BinName())
assert.NotEmpty(t, sysutil.BinFile())
// echo $PSVersionTable.PSVersion.ToString()
// return windows.ShellExecute(0, nil, windows.StringToUTF16Ptr(url), nil, nil, windows.SW_SHOWNORMAL)
dump.P(sysutil.ExecCmd("echo", []string{"$PSVersionTable.PSVersion.ToString()"}))
}
func TestOpenFile(t *testing.T) {
assert.Err(t, sysutil.Open("open_a_invalid_path"))
assert.Err(t, sysutil.OpenFile("open_a_invalid_path"))
assert.Err(t, sysutil.OpenBrowser("open_a_invalid_path"))
}
func TestProcessExists(t *testing.T) {
if runtime.GOOS != "windows" {
pid := os.Getpid()
assert.True(t, sysutil.ProcessExists(pid))
} else {
assert.Panics(t, func() { sysutil.ProcessExists(0) })
}
}