-
Notifications
You must be signed in to change notification settings - Fork 0
/
kind_test.go
68 lines (56 loc) · 1.53 KB
/
kind_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
65
66
67
68
package platform
import (
"io/ioutil"
"path"
"testing"
"github.com/gruntwork-io/terratest/modules/terraform"
"github.com/telliott-io/platform/testing/kind"
"github.com/telliott-io/platform/testing/testdir"
)
func TestWithKind(t *testing.T) {
if testing.Short() {
t.Skip()
}
tfdir := "testdata"
workingDirCleanup, err := testdir.New(tfdir)
if err != nil {
t.Fatal(err)
}
defer workingDirCleanup()
err = ioutil.WriteFile(path.Join(tfdir, "main.tf"), []byte(kindPlatformTF), 0644)
if err != nil {
t.Fatal(err)
}
kubeconfigfile := "kindconfig"
kindCleanup, err := kind.New("platform-test-kind", path.Join(tfdir, kubeconfigfile))
if err != nil {
t.Fatal(err)
}
defer kindCleanup()
terraformOptions := &terraform.Options{
TerraformDir: tfdir,
Vars: map[string]interface{}{},
// EnvVars: map[string]string{
// "TF_LOG": "debug",
// },
}
// At the end of the test, run `terraform destroy`
defer terraform.Destroy(t, terraformOptions)
// Run `terraform init` and `terraform apply`
_ = terraform.InitAndApply(t, terraformOptions)
checkEnvironmentHost(t, "http://localhost:32080", "platform.test", "platform-test")
}
const kindPlatformTF = `
module "platform" {
source = "../"
kubernetes = "{\"config_path\": \"${path.module}/kindconfig\"}"
environment = "platform-test"
hostname = "platform.test"
argocd_admin_password = "secret"
bootstrap_repository = "https://telliott-io.github.io/testbootstrap"
bootstrap_chart = "bootstrap"
bootstrap_version = "0.1.1"
debug = true
service_type = "NodePort"
}
`