Skip to content

Commit 2198573

Browse files
test: added test for getProcList
1 parent 0a5aa82 commit 2198573

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

pkg/procInfo_test.go

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package psutils
2+
3+
import (
4+
"testing"
5+
6+
"github.com/stretchr/testify/assert"
7+
)
8+
9+
var procStatus string = `Name: Anything
10+
Umask: 0000
11+
State: R (Running)
12+
Tgid: 4085954
13+
Ngid: 0
14+
Pid: 5
15+
PPid: 2
16+
TracerPid: 0
17+
Uid: 0 0 0 0
18+
Gid: 0 0 0 0
19+
FDSize: 64`
20+
21+
type spyProcLoader struct{}
22+
23+
func (l *spyProcLoader) Load(string) (string, error) {
24+
return procStatus, nil
25+
}
26+
func TestGetProcList(t *testing.T) {
27+
var _ Loader = (*spyProcLoader)(nil)
28+
got, err := getProcessList(&spyProcLoader{})
29+
if err != nil {
30+
t.Errorf("%v", err)
31+
}
32+
expected := Process{
33+
PID: 5,
34+
ProcessName: "Anything",
35+
}
36+
assert.Equal(t, expected, got[0])
37+
38+
}

0 commit comments

Comments
 (0)