-
Notifications
You must be signed in to change notification settings - Fork 17
/
parse_test.go
44 lines (35 loc) · 1.02 KB
/
parse_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
package procs_test
import (
"testing"
"github.com/poy/onpar"
. "github.com/poy/onpar/expect"
. "github.com/poy/onpar/matchers"
"github.com/ionrock/procs"
)
func matchSplitCommand(t *testing.T, parts, expected []string) {
for i, part := range parts {
Expect(t, part).To(Equal(expected[i]))
}
}
func TestSplitCommand(t *testing.T) {
o := onpar.New()
defer o.Run(t)
o.Group("split with pipe", func() {
o.BeforeEach(func(t *testing.T) (*testing.T, []string, []string) {
parts := procs.SplitCommand("echo 'foo' | grep o")
expected := []string{"echo", "foo", "|", "grep", "o"}
return t, parts, expected
})
o.Spec("pass with a pipe", matchSplitCommand)
})
o.Group("replace with specific context", func() {
o.BeforeEach(func(t *testing.T) (*testing.T, []string, []string) {
parts := procs.SplitCommandEnv("echo ${FOO}", func(k string) string {
return "bar"
})
expected := []string{"echo", "bar"}
return t, parts, expected
})
o.Spec("expand values found in provided env", matchSplitCommand)
})
}