Skip to content

Commit

Permalink
Merge pull request #20 from confusdcodr/output_tests
Browse files Browse the repository at this point in the history
Add directory name to test output
  • Loading branch information
confusdcodr authored Oct 1, 2019
2 parents 6459639 + d806b56 commit afdfb44
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 1.0.3
current_version = 1.0.4
commit = True
tag = False
tag_name = {new_version}
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ terraform.tfstate*

# ignore go files
vendor/

# ignore log files
*.log
50 changes: 46 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,20 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).

### 1.0.2
### 1.0.4

**Commit Delta**: [Change from 1.0.3 release] (https://github.com/plus3it/terraform-aws-tardigrade-inspector/compare/1.0.3...1.0.4)

**Released**: 2019.10.01

**Summary**:

* Update testing framework to have a more user-friendly output
* Update CHANGELOG

### 1.0.3

**Commit Delta**: https://github.com/plus3it/terraform-aws-tardigrade-inspector/compare/1.0.1...1.0.2
**Commit Delta**: [Change from 1.0.2 release] (https://github.com/plus3it/terraform-aws-tardigrade-inspector/compare/1.0.2...1.0.3)

**Released**: 2019.09.19

Expand All @@ -16,9 +27,20 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
* Add an additional test
* Update go module versions

### 1.0.2

**Commit Delta**: [Change from 1.0.1 release] (https://github.com/plus3it/terraform-aws-tardigrade-inspector/compare/1.0.1...1.0.2)

**Released**: 2019.09.06

**Summary**:

* Update dependabot configuration to include test cases and go:modules
* Add test cases

### 1.0.1

**Commit Delta**: https://github.com/plus3it/terraform-aws-tardigrade-inspector/compare/1.0.0...1.0.1
**Commit Delta**: [Change from 1.0.0 release] (https://github.com/plus3it/terraform-aws-tardigrade-inspector/compare/1.0.0...1.0.1)

**Released**: 2019.09.05

Expand All @@ -28,14 +50,34 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p

### 1.0.0

**Commit Delta**: https://github.com/plus3it/terraform-aws-tardigrade-inspector/compare/0.0.2...1.0.0
**Commit Delta**: [Change from 0.0.2 release] (https://github.com/plus3it/terraform-aws-tardigrade-inspector/compare/0.0.2...1.0.0)

**Released**: 2019.09.04

**Summary**:

* Upgrade module to use terraform 0.12.x. This is not backwards compatible

### 0.0.2

**Commit Delta**: [Change from 0.0.1 release] (https://github.com/plus3it/terraform-aws-tardigrade-inspector/compare/0.0.1...0.0.2)

**Released**: 2019.08.21

**Summary**:

* Add dependabot

### 0.0.1

**Commit Delta**: [Change from 0.0.0 release] (https://github.com/plus3it/terraform-aws-tardigrade-inspector/compare/0.0.0...0.0.1)

**Released**: 2019.08.19

**Summary**:

* Add testing framework

### 0.0.0

**Commit Delta**: N/A
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,6 @@ terratest/install: | guard/program/go
cd tests && go mod tidy

terratest/test: | guard/program/go
cd tests && go test -timeout 20m
cd tests && go test -count=1 -timeout 20m

test: terratest/test
30 changes: 14 additions & 16 deletions tests/module_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,24 @@ func TestModule(t *testing.T) {
for _, f := range files {
// look for directories with test cases in it
if f.IsDir() && f.Name() != "vendor" {
investigateDirectory(t, f)
t.Run(f.Name(), func(t *testing.T) {
// check if a prereq directory exists
prereqDir := f.Name() + "/prereq/"
if _, err := os.Stat(prereqDir); err == nil {
prereqOptions := createTerraformOptions(prereqDir)
defer terraform.Destroy(t, prereqOptions)
terraform.InitAndApply(t, prereqOptions)
}

// run terraform code for test case
terraformOptions := createTerraformOptions(f.Name())
defer terraform.Destroy(t, terraformOptions)
terraform.InitAndApply(t, terraformOptions)
})
}
}
}

func investigateDirectory(t *testing.T, directory os.FileInfo) {
// check if a prereq directory exists
prereqDir := directory.Name() + "/prereq/"
if _, err := os.Stat(prereqDir); err == nil {
prereqOptions := createTerraformOptions(prereqDir)
defer terraform.Destroy(t, prereqOptions)
terraform.InitAndApply(t, prereqOptions)
}

// run terraform code for test case
terraformOptions := createTerraformOptions(directory.Name())
defer terraform.Destroy(t, terraformOptions)
terraform.InitAndApply(t, terraformOptions)
}

func createTerraformOptions(directory string) *terraform.Options {
terraformOptions := &terraform.Options{
TerraformDir: directory,
Expand Down

0 comments on commit afdfb44

Please sign in to comment.