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

Commit 72ae652

Browse files
committed
Added additional testing
1 parent 0c9ebaf commit 72ae652

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

main_test.go

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,43 @@ func TestTerraformWithTerrafilePath(t *testing.T) {
3838
} {
3939
assert.Contains(t, testcli.Stdout(), output)
4040
}
41-
// Assert files exist
41+
// Assert folder exist
4242
for _, moduleName := range []string{
4343
"tf-aws-vpc",
4444
"tf-aws-vpc-experimental",
4545
} {
4646
assert.DirExists(t, path.Join(workingDirectory, "vendor/modules", moduleName))
4747
}
48+
49+
// Assert files exist
50+
for _, moduleName := range []string{
51+
"tf-aws-vpc/main.tf",
52+
"tf-aws-vpc-experimental/main.tf",
53+
} {
54+
assert.FileExists(t, path.Join(workingDirectory, "vendor/modules", moduleName))
55+
}
56+
57+
// Assert checked out correct version
58+
for moduleName, cloneOptions := range map[string]map[string]string{
59+
"tf-aws-vpc": map[string]string{
60+
"repository": "[email protected]:terraform-aws-modules/terraform-aws-vpc",
61+
"version": "v1.46.0",
62+
},
63+
"tf-aws-vpc-experimental": map[string]string{
64+
"repository": "[email protected]:terraform-aws-modules/terraform-aws-vpc",
65+
"version": "master",
66+
},
67+
} {
68+
testModuleLocation := path.Join(workingDirectory, "vendor/modules", moduleName+"__test")
69+
testcli.Run("git", "clone", "-b", cloneOptions["version"], cloneOptions["repository"], testModuleLocation)
70+
if !testcli.Success() {
71+
t.Fatalf("Expected to succeed, but failed: %q with message: %q", testcli.Error(), testcli.Stderr())
72+
}
73+
testcli.Run("diff", "--exclude=.git", "-r", path.Join(workingDirectory, "vendor/modules", moduleName), testModuleLocation)
74+
if !testcli.Success() {
75+
t.Fatalf("File difference found for %q, with failure: %q with message: %q", moduleName, testcli.Error(), testcli.Stderr())
76+
}
77+
}
4878
}
4979

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

0 commit comments

Comments
 (0)