-
-
Notifications
You must be signed in to change notification settings - Fork 1k
/
Copy pathintegration_exclude_test.go
158 lines (109 loc) · 5.51 KB
/
integration_exclude_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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
package test_test
import (
"github.com/gruntwork-io/terragrunt/test/helpers"
"github.com/gruntwork-io/terragrunt/util"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"testing"
)
const (
testExcludeByDefault = "fixtures/exclude/default"
testExcludeDisabled = "fixtures/exclude/disabled"
testExcludeByAction = "fixtures/exclude/action"
testExcludeByFlags = "fixtures/exclude/feature-flags"
testExcludeDependencies = "fixtures/exclude/dependencies"
testExcludeAllExceptOutput = "fixtures/exclude/all-except-output"
)
func TestExcludeByDefault(t *testing.T) {
t.Parallel()
cleanupTerraformFolder(t, testExcludeByDefault)
tmpEnvPath := helpers.CopyEnvironment(t, testExcludeByDefault)
rootPath := util.JoinPath(tmpEnvPath, testExcludeByDefault)
_, stderr, err := helpers.RunTerragruntCommandWithOutput(t, "terragrunt run-all apply -auto-approve --terragrunt-non-interactive --terragrunt-working-dir "+rootPath)
require.NoError(t, err)
assert.Contains(t, stderr, "app1")
assert.NotContains(t, stderr, "app2")
}
func TestExcludeDisabled(t *testing.T) {
t.Parallel()
cleanupTerraformFolder(t, testExcludeDisabled)
tmpEnvPath := helpers.CopyEnvironment(t, testExcludeDisabled)
rootPath := util.JoinPath(tmpEnvPath, testExcludeDisabled)
_, stderr, err := helpers.RunTerragruntCommandWithOutput(t, "terragrunt run-all apply -auto-approve --terragrunt-non-interactive --terragrunt-working-dir "+rootPath)
require.NoError(t, err)
assert.Contains(t, stderr, "app1")
assert.Contains(t, stderr, "app2")
}
func TestExcludeApply(t *testing.T) {
t.Parallel()
cleanupTerraformFolder(t, testExcludeByAction)
tmpEnvPath := helpers.CopyEnvironment(t, testExcludeByAction)
rootPath := util.JoinPath(tmpEnvPath, testExcludeByAction)
_, stderr, err := helpers.RunTerragruntCommandWithOutput(t, "terragrunt run-all plan --terragrunt-non-interactive --terragrunt-working-dir "+rootPath)
require.NoError(t, err)
assert.Contains(t, stderr, "exclude-apply")
assert.NotContains(t, stderr, "exclude-plan")
_, stderr, err = helpers.RunTerragruntCommandWithOutput(t, "terragrunt run-all apply -auto-approve --terragrunt-non-interactive --terragrunt-working-dir "+rootPath)
require.NoError(t, err)
// should be applied only exclude-plan
assert.Contains(t, stderr, "exclude-plan")
assert.NotContains(t, stderr, "exclude-apply")
}
func TestExcludeByFeatureFlagDefault(t *testing.T) {
t.Parallel()
cleanupTerraformFolder(t, testExcludeByFlags)
tmpEnvPath := helpers.CopyEnvironment(t, testExcludeByFlags)
rootPath := util.JoinPath(tmpEnvPath, testExcludeByFlags)
_, stderr, err := helpers.RunTerragruntCommandWithOutput(t, "terragrunt run-all apply --terragrunt-non-interactive --terragrunt-working-dir "+rootPath)
require.NoError(t, err)
assert.Contains(t, stderr, "app1")
assert.NotContains(t, stderr, "app2")
}
func TestExcludeByFeatureFlag(t *testing.T) {
t.Parallel()
cleanupTerraformFolder(t, testExcludeByFlags)
tmpEnvPath := helpers.CopyEnvironment(t, testExcludeByFlags)
rootPath := util.JoinPath(tmpEnvPath, testExcludeByFlags)
_, stderr, err := helpers.RunTerragruntCommandWithOutput(t, "terragrunt run-all apply --feature exclude2=false --terragrunt-non-interactive --terragrunt-working-dir "+rootPath)
require.NoError(t, err)
assert.Contains(t, stderr, "app1")
assert.Contains(t, stderr, "app2")
}
func TestExcludeAllByFeatureFlag(t *testing.T) {
t.Parallel()
cleanupTerraformFolder(t, testExcludeByFlags)
tmpEnvPath := helpers.CopyEnvironment(t, testExcludeByFlags)
rootPath := util.JoinPath(tmpEnvPath, testExcludeByFlags)
_, stderr, err := helpers.RunTerragruntCommandWithOutput(t, "terragrunt run-all apply --feature exclude1=true --feature exclude2=true --terragrunt-non-interactive --terragrunt-working-dir "+rootPath)
require.NoError(t, err)
assert.NotContains(t, stderr, "app1")
assert.NotContains(t, stderr, "app2")
}
func TestExcludeDependencies(t *testing.T) {
t.Parallel()
cleanupTerraformFolder(t, testExcludeDependencies)
tmpEnvPath := helpers.CopyEnvironment(t, testExcludeDependencies)
rootPath := util.JoinPath(tmpEnvPath, testExcludeDependencies)
_, stderr, err := helpers.RunTerragruntCommandWithOutput(t, "terragrunt run-all apply -auto-approve --feature exclude=false --feature exclude_dependencies=false --terragrunt-non-interactive --terragrunt-working-dir "+rootPath)
require.NoError(t, err)
assert.Contains(t, stderr, "dep")
assert.Contains(t, stderr, "app1")
_, stderr, err = helpers.RunTerragruntCommandWithOutput(t, "terragrunt run-all apply -auto-approve --feature exclude=true --feature exclude_dependencies=false --terragrunt-non-interactive --terragrunt-working-dir "+rootPath)
require.NoError(t, err)
assert.Contains(t, stderr, "dep")
assert.NotContains(t, stderr, "app1")
}
func TestExcludeAllExceptOutput(t *testing.T) {
t.Parallel()
cleanupTerraformFolder(t, testExcludeAllExceptOutput)
tmpEnvPath := helpers.CopyEnvironment(t, testExcludeAllExceptOutput)
rootPath := util.JoinPath(tmpEnvPath, testExcludeAllExceptOutput)
_, stderr, err := helpers.RunTerragruntCommandWithOutput(t, "terragrunt run-all apply -auto-approve --terragrunt-non-interactive --terragrunt-working-dir "+rootPath)
require.NoError(t, err)
assert.NotContains(t, stderr, "app1")
assert.Contains(t, stderr, "app2")
_, stderr, err = helpers.RunTerragruntCommandWithOutput(t, "terragrunt run-all output --terragrunt-non-interactive --terragrunt-working-dir "+rootPath)
require.NoError(t, err)
assert.Contains(t, stderr, "app1")
assert.Contains(t, stderr, "app2")
}