Skip to content

Commit

Permalink
Merge pull request #20 from confusdcodr/test_output
Browse files Browse the repository at this point in the history
Update test harness
  • Loading branch information
confusdcodr authored Oct 3, 2019
2 parents b65cd8c + ab13fcb commit a288665
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 18 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.0
current_version = 1.0.1
commit = True
message = Bumps version to {new_version}
tag = False
Expand Down
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@ 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.1

**Released**: 2019.10.03

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

**Summary**:

* Update testing harness to have a more user-friendly output
* Update terratest dependencies

### 1.0.0

**Released**: 2019.09.23
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ make clean && make vendor
| config\_bucket | Name of S3 bucket to validate that Config is configured to send inventory to | string | `"null"` | no |
| config\_recorder | The name of the AWS Config recorder | string | `"null"` | no |
| config\_sns\_topic\_arn | ARN of SNS topic to validate that Config changes are being streamed to | string | `"null"` | no |
| create\_config\_rules | Controls whether to create the AWS Config Rules | string | `"true"` | no |
| create\_config\_rules | Controls whether to create the AWS Config Rules | bool | `"true"` | no |
| exclude\_rules | List of config rule resource names to exclude from creation | list(string) | `<list>` | no |
| tags | Map of tags to apply to the resources | map(string) | `<map>` | no |

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
1 change: 1 addition & 0 deletions variables.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
variable "create_config_rules" {
description = "Controls whether to create the AWS Config Rules"
type = bool
default = true
}

Expand Down

0 comments on commit a288665

Please sign in to comment.