forked from k1LoW/runn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexec_test.go
49 lines (46 loc) · 913 Bytes
/
exec_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
package runn
import (
"context"
"testing"
"github.com/google/go-cmp/cmp"
)
func TestExecRun(t *testing.T) {
tests := []struct {
command string
stdin string
want map[string]interface{}
}{
{"echo hello!!", "", map[string]interface{}{
"stdout": "hello!!\n",
"stderr": "",
"exit_code": 0,
"run": true,
}},
{"cat", "hello!!", map[string]interface{}{
"stdout": "hello!!",
"stderr": "",
"exit_code": 0,
"run": true,
}},
}
ctx := context.Background()
for _, tt := range tests {
o, err := New()
if err != nil {
t.Fatal(err)
}
r, err := newExecRunner(o)
if err != nil {
t.Fatal(err)
}
c := &execCommand{command: tt.command, stdin: tt.stdin}
if err := r.Run(ctx, c); err != nil {
t.Error(err)
return
}
got := o.store.steps[0]
if diff := cmp.Diff(got, tt.want, nil); diff != "" {
t.Errorf("%s", diff)
}
}
}