-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
integration_test.go
39 lines (34 loc) · 988 Bytes
/
integration_test.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
// +build integration
package main
import (
"os"
"testing"
"github.com/gruntwork-io/terratest/modules/terraform"
)
func getAPIKey(t *testing.T) string {
key := os.Getenv("CHECKLY_API_KEY")
if key == "" {
t.Fatal("'CHECKLY_API_KEY' must be set for integration tests")
}
return key
}
func TestChecklyTerraformIntegration(t *testing.T) {
t.Parallel()
terraformOptions := &terraform.Options{
TerraformDir: ".",
Vars: map[string]interface{}{
"checkly_api_key": getAPIKey(t),
},
}
defer terraform.Destroy(t, terraformOptions)
terraform.InitAndApply(t, terraformOptions)
planPath := "./test.plan"
exit, err := terraform.GetExitCodeForTerraformCommandE(t, terraformOptions, terraform.FormatArgs(terraformOptions, "plan", "--out="+planPath, "-input=false", "-lock=true", "-detailed-exitcode")...)
if err != nil {
t.Fatal(err)
}
defer os.Remove(planPath)
if exit != terraform.DefaultSuccessExitCode {
t.Fatalf("want DefaultSuccessExitCode, got %d", exit)
}
}