Skip to content
This repository has been archived by the owner on Mar 19, 2024. It is now read-only.

Commit

Permalink
Added additional testing
Browse files Browse the repository at this point in the history
  • Loading branch information
nritholtz committed Apr 7, 2019
1 parent 0c9ebaf commit 72ae652
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,43 @@ func TestTerraformWithTerrafilePath(t *testing.T) {
} {
assert.Contains(t, testcli.Stdout(), output)
}
// Assert files exist
// Assert folder exist
for _, moduleName := range []string{
"tf-aws-vpc",
"tf-aws-vpc-experimental",
} {
assert.DirExists(t, path.Join(workingDirectory, "vendor/modules", moduleName))
}

// Assert files exist
for _, moduleName := range []string{
"tf-aws-vpc/main.tf",
"tf-aws-vpc-experimental/main.tf",
} {
assert.FileExists(t, path.Join(workingDirectory, "vendor/modules", moduleName))
}

// Assert checked out correct version
for moduleName, cloneOptions := range map[string]map[string]string{
"tf-aws-vpc": map[string]string{
"repository": "git@github.com:terraform-aws-modules/terraform-aws-vpc",
"version": "v1.46.0",
},
"tf-aws-vpc-experimental": map[string]string{
"repository": "git@github.com:terraform-aws-modules/terraform-aws-vpc",
"version": "master",
},
} {
testModuleLocation := path.Join(workingDirectory, "vendor/modules", moduleName+"__test")
testcli.Run("git", "clone", "-b", cloneOptions["version"], cloneOptions["repository"], testModuleLocation)
if !testcli.Success() {
t.Fatalf("Expected to succeed, but failed: %q with message: %q", testcli.Error(), testcli.Stderr())
}
testcli.Run("diff", "--exclude=.git", "-r", path.Join(workingDirectory, "vendor/modules", moduleName), testModuleLocation)
if !testcli.Success() {
t.Fatalf("File difference found for %q, with failure: %q with message: %q", moduleName, testcli.Error(), testcli.Stderr())
}
}
}

func setup(t *testing.T) (current string, back func()) {
Expand Down

0 comments on commit 72ae652

Please sign in to comment.