-
Notifications
You must be signed in to change notification settings - Fork 3
/
single_test.go
63 lines (56 loc) · 1.22 KB
/
single_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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package goproc
import (
"fmt"
"testing"
"github.com/zeebo/assert"
)
func TestNotExists(t *testing.T) {
proc := NewWithCleanup()
proc.AddCommand(&Cmd{
Program: `not_exists`,
})
wg := proc.StartAllParallel()
wg.Wait()
fmt.Println(`done`)
}
func TestRun1(t *testing.T) {
stdout, stderr, err, exitCode := Run1(&Cmd{
Program: `echo`,
Parameters: []string{`1`},
})
assert.Equal(t, "1\n", stdout)
assert.Equal(t, "", stderr)
assert.NoError(t, err)
assert.Equal(t, 0, exitCode)
}
func TestRun1missing(t *testing.T) {
stdout, stderr, err, exitCode := Run1(&Cmd{
Program: `not_found`,
Parameters: []string{`1`},
})
assert.Equal(t, "", stdout)
assert.Equal(t, "", stderr)
assert.Error(t, err)
assert.Equal(t, 0, exitCode)
}
func TestRun1long(t *testing.T) {
_, stderr, err, exitCode := Run1(&Cmd{
Program: `ls`,
Parameters: []string{`-alr`},
})
assert.Equal(t, "", stderr)
assert.NoError(t, err)
assert.Equal(t, 0, exitCode)
}
func TestRunLineslong(t *testing.T) {
stdout, stderr, err, exitCode := RunLines(&Cmd{
Program: `ls`,
Parameters: []string{`-alr`},
})
for _, line := range stdout {
_ = line
}
assert.Equal(t, []string{}, stderr)
assert.NoError(t, err)
assert.Equal(t, 0, exitCode)
}