setuptest/init.go (23 lines of code) (raw):

package setuptest import ( "testing" "github.com/gruntwork-io/terratest/modules/terraform" ) // Init is a wrapper around terraform.InitE // It takes a test object as a parameter and returns a setuptest.Response. // // The response contains the temporary directory, the plan, the Terraform options and a cleanup function. // The temporary directory is the directory containing a copy of the code specified by the Dirs func. // The plan is the plan struct generated by terraform, which can be used by the check package - will be empty, as no plan is generated. // If you want a plan struct use the InitPlanShow method. // The cleanup function provides coherent logging and also will clean up the temporary directory - use with defer. func (dtv DirTypeWithVars) Init(t *testing.T) (Response, error) { resp, err := setup(t, dtv.RootDir, dtv.TestDir, nil) if err != nil { return resp, err } resp.Options.Vars = dtv.Vars _, err = terraform.InitE(t, resp.Options) return resp, err } // Init is a wrapper around terraform.InitE // It takes a test object as a parameter and returns a setuptest.Response. // // The response contains the temporary directory, the plan, the Terraform options and a cleanup function. // The temporary directory is the directory containing a copy of the code specified by the Dirs func. // The plan is the plan struct generated by terraform, which can be used by the check package - will be empty, as no plan is generated. // If you want a plan struct use the InitPlanShow method. // The cleanup function provides coherent logging and also will clean up the temporary directory - use with defer. func (dtvf DirTypeWithVarFiles) Init(t *testing.T) (Response, error) { resp, err := setup(t, dtvf.RootDir, dtvf.TestDir, nil) if err != nil { return resp, err } resp.Options.VarFiles = dtvf.VarFiles _, err = terraform.InitE(t, resp.Options) return resp, err }