Skip to content

Commit e20ca37

Browse files
committed
Include TERRATEST_REGION in check
1 parent 2520157 commit e20ca37

File tree

4 files changed

+43
-2
lines changed

4 files changed

+43
-2
lines changed

hooks/check_skip_env.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
def has_setenv_skip(fpath):
1212
with open(fpath) as f:
1313
for line in f:
14-
if re.match(r'^\s+os.Setenv\(\"SKIP_', line):
14+
if re.match(r'^\s+os.Setenv\(\"(SKIP_|TERRATEST_REGION)', line):
1515
return True
1616
return False
1717

test/check_skip_env_test.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ def test_skip_uncommented(self):
3434
test_file_path = os.path.join(self.fixture_dir, 'skip_uncommented_test.go')
3535
self._check_failure([test_file_path], [test_file_path])
3636

37+
def test_terratest_region_uncommented(self):
38+
test_file_path = os.path.join(self.fixture_dir, 'terratest_region_uncommented_test.go')
39+
self._check_failure([test_file_path], [test_file_path])
40+
3741
def test_multiple_skip_uncommented(self):
3842
test_file_path = os.path.join(self.fixture_dir, 'multiple_skip_uncommented_test.go')
3943
self._check_failure([test_file_path], [test_file_path])
@@ -48,6 +52,7 @@ def test_everything(self):
4852
os.path.join(self.fixture_dir, 'skip_uncommented_test.go'),
4953
os.path.join(self.fixture_dir, 'multiple_skip_uncommented_test.go'),
5054
os.path.join(self.fixture_dir, 'nested_uncommented_test.go'),
55+
os.path.join(self.fixture_dir, 'terratest_region_uncommented_test.go'),
5156
]
5257
self._check_failure(all_test_files, failed_files)
5358

test/fixtures/non_skip_uncommented_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ func TestWithStages(t *testing.T) {
1212
t.Parallel()
1313

1414
// Uncomment the items below to skip certain parts of the test
15-
os.Setenv("TERRATEST_REGION", "eu-west-1")
15+
os.Setenv("THE_ANSWER", "42")
1616
//os.Setenv("SKIP_setup", "true")
1717
//os.Setenv("SKIP_deploy", "true")
1818
//os.Setenv("SKIP_validate", "true")
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package basecase
2+
3+
import (
4+
"os"
5+
"testing"
6+
7+
"github.com/gruntwork-io/terratest/modules/logger"
8+
test_structure "github.com/gruntwork-io/terratest/modules/test-structure"
9+
)
10+
11+
func TestWithStages(t *testing.T) {
12+
t.Parallel()
13+
14+
// Uncomment the items below to skip certain parts of the test
15+
os.Setenv("TERRATEST_REGION", "eu-west-1")
16+
//os.Setenv("SKIP_setup", "true")
17+
//os.Setenv("SKIP_deploy", "true")
18+
//os.Setenv("SKIP_validate", "true")
19+
//os.Setenv("SKIP_cleanup", "true")
20+
21+
test_structure.RunTestStage(t, "setup", func() {
22+
logger.Logf(t, "setup")
23+
})
24+
25+
defer test_structure.RunTestStage(t, "cleanup", func() {
26+
logger.Logf(t, "cleanup")
27+
})
28+
29+
test_structure.RunTestStage(t, "deploy", func() {
30+
logger.Logf(t, "deploy")
31+
})
32+
33+
test_structure.RunTestStage(t, "validate", func() {
34+
logger.Logf(t, "validate")
35+
})
36+
}

0 commit comments

Comments
 (0)