-
Notifications
You must be signed in to change notification settings - Fork 17
/
builder_test.go
58 lines (48 loc) · 1.24 KB
/
builder_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
package procs_test
import (
"testing"
"github.com/ionrock/procs"
)
func TestCommandContext(t *testing.T) {
b := &procs.Builder{
Context: map[string]string{
"options": "-Fj -s https://example.com/chef -k knife.pem",
},
Templates: []string{
"knife",
"${model} ${action}",
"${args}",
"${options}",
},
}
cmd := b.CommandContext(map[string]string{
"model": "data bag",
"action": "from file",
"args": "foo data_bags/foo/bar.json",
})
expected := "knife data bag from file foo data_bags/foo/bar.json -Fj -s https://example.com/chef -k knife.pem"
if cmd != expected {
t.Fatalf("failed building command: %q != %q", cmd, expected)
}
}
func TestCommand(t *testing.T) {
b := &procs.Builder{
Context: map[string]string{
"options": "-Fj -s https://example.com/chef -k knife.pem",
"model": "data bag",
"action": "from file",
"args": "foo data_bags/foo/bar.json",
},
Templates: []string{
"knife",
"${model} ${action}",
"${args}",
"${options}",
},
}
cmd := b.CommandContext(map[string]string{})
expected := "knife data bag from file foo data_bags/foo/bar.json -Fj -s https://example.com/chef -k knife.pem"
if cmd != expected {
t.Fatalf("failed building command: %q != %q", cmd, expected)
}
}