forked from hashicorp/terraform-exec
/
state_push_test.go
48 lines (39 loc) · 920 Bytes
/
state_push_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
package tfexec
import (
"context"
"testing"
"github.com/hashicorp/terraform-exec/tfexec/internal/testutil"
)
func TestStatePushCmd(t *testing.T) {
td := testTempDir(t)
tf, err := NewTerraform(td, tfVersion(t, testutil.Latest_v1))
if err != nil {
t.Fatal(err)
}
tf.SetEnv(map[string]string{})
t.Run("defaults", func(t *testing.T) {
statePushCmd, err := tf.statePushCmd(context.Background(), "testpath")
if err != nil {
t.Fatal(err)
}
assertCmd(t, []string{
"state",
"push",
"-lock=false",
"-lock-timeout=0s",
}, nil, statePushCmd)
})
t.Run("override all defaults", func(t *testing.T) {
statePushCmd, err := tf.statePushCmd(context.Background(), "testpath", Force(true), Lock(true), LockTimeout("10s"))
if err != nil {
t.Fatal(err)
}
assertCmd(t, []string{
"state",
"push",
"-force",
"-lock=true",
"-lock-timeout=10s",
}, nil, statePushCmd)
})
}