@@ -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
5080func setup (t * testing.T ) (current string , back func ()) {
0 commit comments