-
Notifications
You must be signed in to change notification settings - Fork 2
/
init.go
43 lines (39 loc) · 1.85 KB
/
init.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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
}