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/apoydence/onpar"
. "github.com/apoydence/onpar/expect"
. "github.com/apoydence/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)
})
}
|