Skip to content

Commit 0238e09

Browse files
committed
WIP: Add two unit test files
1 parent 90174fe commit 0238e09

File tree

2 files changed

+225
-0
lines changed

2 files changed

+225
-0
lines changed

tests/prefix.tftest.hcl

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
variables {
2+
location = "eastus2"
3+
}
4+
5+
run "prefix_length_too_short" {
6+
7+
command = plan
8+
9+
variables {
10+
prefix = "ba"
11+
}
12+
13+
expect_failures = [
14+
var.prefix,
15+
]
16+
}
17+
18+
run "prefix_disallowed_char" {
19+
20+
command = plan
21+
22+
variables {
23+
prefix = "foo*"
24+
}
25+
26+
expect_failures = [
27+
var.prefix,
28+
]
29+
}
30+
31+
run "prefix_dissallowed_uppercase" {
32+
33+
command = plan
34+
35+
variables {
36+
prefix = "Foobar"
37+
}
38+
39+
expect_failures = [
40+
var.prefix,
41+
]
42+
}
43+
44+
run "prefix_cannot_start_with_dash" {
45+
46+
command = plan
47+
48+
variables {
49+
prefix = "-bar"
50+
}
51+
52+
expect_failures = [
53+
var.prefix,
54+
]
55+
}
56+
57+
run "prefix_cannot_end_with_dash" {
58+
59+
command = plan
60+
61+
variables {
62+
prefix = "ba-"
63+
}
64+
65+
expect_failures = [
66+
var.prefix,
67+
]
68+
}
69+
70+
run "prefix_length_ok_internal_dash" {
71+
72+
command = plan
73+
74+
variables {
75+
prefix = "my-prefix"
76+
}
77+
}
78+
79+
80+
run "prefix_length_ok_with_number" {
81+
82+
command = plan
83+
84+
variables {
85+
prefix = "my-prefix21"
86+
}
87+
}

tests/var_defaults.tftest.hcl

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
2+
variables {
3+
location = "eastus2"
4+
prefix = "foobar"
5+
}
6+
7+
run "default_cluster_sku_tier" {
8+
9+
command = plan
10+
11+
variables {
12+
}
13+
14+
assert {
15+
condition = var.aks_cluster_sku_tier == "Free"
16+
error_message = "A default value of \"${var.aks_cluster_sku_tier}\" for aks_cluster_sku_tier was not expected."
17+
}
18+
}
19+
20+
run "default_cluster_support_tier" {
21+
22+
command = plan
23+
24+
variables {
25+
}
26+
27+
assert {
28+
condition = var.cluster_support_tier == "KubernetesOfficial"
29+
error_message = "A default value of \"${var.cluster_support_tier}\" for aks_cluster_support_tier was not expected."
30+
}
31+
}
32+
33+
run "aks_network_plugin" {
34+
35+
command = plan
36+
37+
variables {
38+
}
39+
40+
assert {
41+
condition = var.aks_network_plugin == "kubenet"
42+
error_message = "A default value of \"${var.aks_network_plugin}\" for aks_network_plugin was not expected."
43+
}
44+
}
45+
46+
run "cluster_egress_type" {
47+
48+
command = plan
49+
50+
variables {
51+
}
52+
53+
assert {
54+
condition = var.cluster_egress_type != null ? var.cluster_egress_type == "loadBalancer" : false
55+
error_message = "A default value of \"${var.cluster_egress_type != null ? var.cluster_egress_type : "null"}\" for cluster_egress_type was not expected."
56+
}
57+
58+
# "${var.my_var != null ? var.my_var : "default value"}"
59+
60+
}
61+
62+
run "storage_type" {
63+
64+
command = plan
65+
66+
variables {
67+
}
68+
69+
assert {
70+
condition = var.storage_type == "standard"
71+
error_message = "A default value of \"${var.storage_type}\" for storage_type was not expected."
72+
}
73+
}
74+
75+
run "netapp_size_in_tb" {
76+
77+
command = plan
78+
79+
variables {
80+
}
81+
82+
assert {
83+
condition = var.netapp_size_in_tb != null ? var.netapp_size_in_tb == 4 : false
84+
error_message = "A default value of \"${var.netapp_size_in_tb}\" for netapp_size_in_tb was not expected."
85+
}
86+
}
87+
88+
run "netapp_network_features" {
89+
90+
command = plan
91+
92+
variables {
93+
}
94+
95+
assert {
96+
condition = var.netapp_network_features != null ? var.netapp_network_features == "Basic" : false
97+
error_message = "A default value of \"${var.netapp_network_features != null ? var.netapp_network_features : "null"}\" for netapp_network_features was not expected."
98+
}
99+
}
100+
101+
run "metrics_category" {
102+
103+
command = plan
104+
105+
variables {
106+
}
107+
108+
assert {
109+
condition = var.metric_category.0 == "AllMetrics"
110+
error_message = "A default value of \"${var.metric_category.0}\" for metrics_category was not expected."
111+
}
112+
}
113+
114+
run "cluster_api_mode" {
115+
116+
command = plan
117+
118+
variables {
119+
}
120+
121+
assert {
122+
condition = var.cluster_api_mode == "public"
123+
error_message = "A default value of \"${var.cluster_api_mode}\" for cluster_api_mode was not expected."
124+
}
125+
}
126+
127+
run "aks_identity" {
128+
129+
command = plan
130+
131+
variables {
132+
}
133+
134+
assert {
135+
condition = var.aks_identity == "uai"
136+
error_message = "A default value of \"${var.aks_identity}\" for aks_identity was not expected."
137+
}
138+
}

0 commit comments

Comments
 (0)