-
Notifications
You must be signed in to change notification settings - Fork 108
/
state_rm_test.go
56 lines (47 loc) · 1.18 KB
/
state_rm_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 TestStateRmCmd(t *testing.T) {
td := t.TempDir()
tf, err := NewTerraform(td, tfVersion(t, testutil.Latest_v1))
if err != nil {
t.Fatal(err)
}
// empty env, to avoid environ mismatch in testing
tf.SetEnv(map[string]string{})
t.Run("defaults", func(t *testing.T) {
stateRmCmd, err := tf.stateRmCmd(context.Background(), "testAddress")
if err != nil {
t.Fatal(err)
}
assertCmd(t, []string{
"state",
"rm",
"-no-color",
"-lock-timeout=0s",
"-lock=true",
"testAddress",
}, nil, stateRmCmd)
})
t.Run("override all defaults", func(t *testing.T) {
stateRmCmd, err := tf.stateRmCmd(context.Background(), "testAddress", Backup("testbackup"), BackupOut("testbackupout"), LockTimeout("200s"), State("teststate"), StateOut("teststateout"), Lock(false))
if err != nil {
t.Fatal(err)
}
assertCmd(t, []string{
"state",
"rm",
"-no-color",
"-backup=testbackup",
"-backup-out=testbackupout",
"-lock-timeout=200s",
"-state=teststate",
"-state-out=teststateout",
"-lock=false",
"testAddress",
}, nil, stateRmCmd)
})
}