-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain_test.go
64 lines (56 loc) · 1.94 KB
/
main_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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package main
import (
"encoding/json"
"github.com/gruntwork-io/terratest/modules/terraform"
"github.com/stretchr/testify/assert"
"reflect"
//"strings"
"testing"
)
type outputWorkerBrief struct {
AioShowAppInstances bool `json:"aio_show_app_instances"`
AioShowAppTemplates bool `json:"aio_show_app_templates"`
AioShowDeployableApps bool `json:"aio_show_deployable_apps"`
BackableHost string `json:"backable_host"`
CaepEdgehost []struct {
AioBackupVol string `json:"aio_backup_vol"`
AioBrief string `json:"aio_brief"`
AioIP string `json:"aio_ip"`
AppDeployable []struct {
AppName string `json:"app_name"`
AppType string `json:"app_type"`
Flavor string `json:"flavor"`
} `json:"app_deployable"`
AppInstances []interface{} `json:"app_instances"`
AppTemplates []struct {
AppName string `json:"app_name"`
AppType string `json:"app_type"`
Flavor string `json:"flavor"`
} `json:"app_templates"`
} `json:"caep_edgehost"`
FilterPattern string `json:"filter_pattern"`
ID string `json:"id"`
WorkerIP string `json:"worker_ip"`
}
func TestTerraformHelloWorldExample(t *testing.T) {
// retryable errors in terraform testing.
terraformOptions := terraform.WithDefaultRetryableErrors(t, &terraform.Options{
TerraformDir: "./examples",
})
defer terraform.Destroy(t, terraformOptions)
terraform.InitAndApply(t, terraformOptions)
output := terraform.OutputJson(t, terraformOptions, "outWorkerBrief1")
t.Logf("%+v", output)
//out := output.(map[string]interface{})
var out outputWorkerBrief
err := json.Unmarshal([]byte(output), &out)
t.Logf("%v\n %+v\n %v %v", err, out, reflect.TypeOf(out), reflect.TypeOf(output))
assert.Less(t, 0, len(out.CaepEdgehost))
if out.AioShowDeployableApps {
assert.NotEqual(t, 0, len(out.CaepEdgehost[0].AppDeployable))
}
if !out.AioShowAppInstances {
assert.Equal(t, 0, len(out.CaepEdgehost[0].AppInstances))
}
assert.Equal(t, 1, 1)
}