@@ -38,13 +38,43 @@ func TestTerraformWithTerrafilePath(t *testing.T) {
38
38
} {
39
39
assert .Contains (t , testcli .Stdout (), output )
40
40
}
41
- // Assert files exist
41
+ // Assert folder exist
42
42
for _ , moduleName := range []string {
43
43
"tf-aws-vpc" ,
44
44
"tf-aws-vpc-experimental" ,
45
45
} {
46
46
assert .DirExists (t , path .Join (workingDirectory , "vendor/modules" , moduleName ))
47
47
}
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
+ }
48
78
}
49
79
50
80
func setup (t * testing.T ) (current string , back func ()) {
0 commit comments