-
Notifications
You must be signed in to change notification settings - Fork 108
/
add_test.go
56 lines (47 loc) · 1012 Bytes
/
add_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
package tfexec
import (
"context"
"testing"
"github.com/hashicorp/terraform-exec/tfexec/internal/testutil"
)
func TestAddCmd(t *testing.T) {
td := t.TempDir()
tf, err := NewTerraform(td, tfVersion(t, testutil.Latest_v1_1))
if err != nil {
t.Fatal(err)
}
// empty env, to avoid environ mismatch in testing
tf.SetEnv(map[string]string{})
t.Run("default", func(t *testing.T) {
addCmd, err := tf.addCmd(context.Background(), "my-addr")
if err != nil {
t.Fatal(err)
}
assertCmd(t, []string{
"add",
"-from-state=false",
"-optional=false",
"my-addr",
}, nil, addCmd)
})
t.Run("override-default", func(t *testing.T) {
addCmd, err := tf.addCmd(context.Background(),
"my-addr",
FromState(true),
Out("out"),
IncludeOptional(true),
Provider("my-provider"),
)
if err != nil {
t.Fatal(err)
}
assertCmd(t, []string{
"add",
"-from-state=true",
"-out=out",
"-optional=true",
"-provider=my-provider",
"my-addr",
}, nil, addCmd)
})
}