-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathprocesses_test.go
36 lines (33 loc) · 990 Bytes
/
processes_test.go
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 goutils
import (
"testing"
. "github.com/smartystreets/goconvey/convey"
)
func Test_execute0(t *testing.T) {
Convey("execute 0", t, func() {
out, _, err := Process.Execute(10, nil, "/bin/echo", "hi")
So(string(out), ShouldEqual, "hi\n")
So(err, ShouldEqual, nil)
})
Convey("execute 1", t, func() {
_, _, err := Process.Execute(1, nil, "/bin/sleep", "2")
So(err, ShouldNotEqual, nil)
})
Convey("execute 2", t, func() {
out, _, err := Process.Execute(2, nil, "/bin/sleep", "1")
So(string(out), ShouldEqual, "")
So(err, ShouldEqual, nil)
})
Convey("execute 3", t, func() {
_, _, err := Process.Execute(2, nil, "/bin/not_existent", "1")
So(err, ShouldNotEqual, nil)
})
Convey("execute 4", t, func() {
text := []byte("text")
ret, stderr, err := Process.Execute(2, text, "/bin/cat", "-")
So(err, ShouldEqual, nil)
So(ret, ShouldNotEqual, nil)
So(string(stderr), ShouldEqual, string([]byte{}))
So(string(text), ShouldEqual, string(ret))
})
}