1
- //go:build linux
2
-
3
1
package terraform_test
4
2
5
3
import (
@@ -26,11 +24,150 @@ func TestParse(t *testing.T) {
26
24
// error containing this string before a Complete response is returned.
27
25
ErrorContains string
28
26
}{
27
+ // {
28
+ // Name: "single-variable",
29
+ // Files: map[string]string{
30
+ // "main.tf": `variable "A" {
31
+ // description = "Testing!"
32
+ // }`,
33
+ // },
34
+ // Response: &proto.Parse_Response{
35
+ // Type: &proto.Parse_Response_Complete{
36
+ // Complete: &proto.Parse_Complete{
37
+ // ParameterSchemas: []*proto.ParameterSchema{{
38
+ // Name: "A",
39
+ // RedisplayValue: true,
40
+ // AllowOverrideSource: true,
41
+ // Description: "Testing!",
42
+ // DefaultDestination: &proto.ParameterDestination{
43
+ // Scheme: proto.ParameterDestination_PROVISIONER_VARIABLE,
44
+ // },
45
+ // }},
46
+ // },
47
+ // },
48
+ // },
49
+ // },
50
+ // {
51
+ // Name: "default-variable-value",
52
+ // Files: map[string]string{
53
+ // "main.tf": `variable "A" {
54
+ // default = "wow"
55
+ // }`,
56
+ // },
57
+ // Response: &proto.Parse_Response{
58
+ // Type: &proto.Parse_Response_Complete{
59
+ // Complete: &proto.Parse_Complete{
60
+ // ParameterSchemas: []*proto.ParameterSchema{{
61
+ // Name: "A",
62
+ // RedisplayValue: true,
63
+ // AllowOverrideSource: true,
64
+ // DefaultSource: &proto.ParameterSource{
65
+ // Scheme: proto.ParameterSource_DATA,
66
+ // Value: "wow",
67
+ // },
68
+ // DefaultDestination: &proto.ParameterDestination{
69
+ // Scheme: proto.ParameterDestination_PROVISIONER_VARIABLE,
70
+ // },
71
+ // }},
72
+ // },
73
+ // },
74
+ // },
75
+ // },
76
+ // {
77
+ // Name: "variable-validation",
78
+ // Files: map[string]string{
79
+ // "main.tf": `variable "A" {
80
+ // validation {
81
+ // condition = var.A == "value"
82
+ // }
83
+ // }`,
84
+ // },
85
+ // Response: &proto.Parse_Response{
86
+ // Type: &proto.Parse_Response_Complete{
87
+ // Complete: &proto.Parse_Complete{
88
+ // ParameterSchemas: []*proto.ParameterSchema{{
89
+ // Name: "A",
90
+ // RedisplayValue: true,
91
+ // ValidationCondition: `var.A == "value"`,
92
+ // ValidationTypeSystem: proto.ParameterSchema_HCL,
93
+ // AllowOverrideSource: true,
94
+ // DefaultDestination: &proto.ParameterDestination{
95
+ // Scheme: proto.ParameterDestination_PROVISIONER_VARIABLE,
96
+ // },
97
+ // }},
98
+ // },
99
+ // },
100
+ // },
101
+ // },
102
+ // {
103
+ // Name: "bad-syntax",
104
+ // Files: map[string]string{
105
+ // "main.tf": "a;sd;ajsd;lajsd;lasjdf;a",
106
+ // },
107
+ // ErrorContains: `The ";" character is not valid.`,
108
+ // },
109
+ // {
110
+ // Name: "multiple-variables",
111
+ // Files: map[string]string{
112
+ // "main1.tf": `variable "foo" { }
113
+ // variable "bar" { }`,
114
+ // "main2.tf": `variable "baz" { }
115
+ // variable "quux" { }`,
116
+ // },
117
+ // Response: &proto.Parse_Response{
118
+ // Type: &proto.Parse_Response_Complete{
119
+ // Complete: &proto.Parse_Complete{
120
+ // ParameterSchemas: []*proto.ParameterSchema{
121
+ // {
122
+ // Name: "foo",
123
+ // RedisplayValue: true,
124
+ // AllowOverrideSource: true,
125
+ // Description: "",
126
+ // DefaultDestination: &proto.ParameterDestination{
127
+ // Scheme: proto.ParameterDestination_PROVISIONER_VARIABLE,
128
+ // },
129
+ // },
130
+ // {
131
+ // Name: "bar",
132
+ // RedisplayValue: true,
133
+ // AllowOverrideSource: true,
134
+ // Description: "",
135
+ // DefaultDestination: &proto.ParameterDestination{
136
+ // Scheme: proto.ParameterDestination_PROVISIONER_VARIABLE,
137
+ // },
138
+ // },
139
+ // {
140
+ // Name: "baz",
141
+ // RedisplayValue: true,
142
+ // AllowOverrideSource: true,
143
+ // Description: "",
144
+ // DefaultDestination: &proto.ParameterDestination{
145
+ // Scheme: proto.ParameterDestination_PROVISIONER_VARIABLE,
146
+ // },
147
+ // },
148
+ // {
149
+ // Name: "quux",
150
+ // RedisplayValue: true,
151
+ // AllowOverrideSource: true,
152
+ // Description: "",
153
+ // DefaultDestination: &proto.ParameterDestination{
154
+ // Scheme: proto.ParameterDestination_PROVISIONER_VARIABLE,
155
+ // },
156
+ // },
157
+ // },
158
+ // },
159
+ // },
160
+ // },
161
+ // },
29
162
{
30
- Name : "single-variable " ,
163
+ Name : "enable-managed-variables " ,
31
164
Files : map [string ]string {
32
165
"main.tf" : `variable "A" {
33
166
description = "Testing!"
167
+ }
168
+
169
+ provider "coder" {
170
+ enable_managed_variables = "true"
34
171
}` ,
35
172
},
36
173
Response : & proto.Parse_Response {
@@ -48,118 +185,7 @@ func TestParse(t *testing.T) {
48
185
},
49
186
},
50
187
},
51
- },
52
- {
53
- Name : "default-variable-value" ,
54
- Files : map [string ]string {
55
- "main.tf" : `variable "A" {
56
- default = "wow"
57
- }` ,
58
- },
59
- Response : & proto.Parse_Response {
60
- Type : & proto.Parse_Response_Complete {
61
- Complete : & proto.Parse_Complete {
62
- ParameterSchemas : []* proto.ParameterSchema {{
63
- Name : "A" ,
64
- RedisplayValue : true ,
65
- AllowOverrideSource : true ,
66
- DefaultSource : & proto.ParameterSource {
67
- Scheme : proto .ParameterSource_DATA ,
68
- Value : "wow" ,
69
- },
70
- DefaultDestination : & proto.ParameterDestination {
71
- Scheme : proto .ParameterDestination_PROVISIONER_VARIABLE ,
72
- },
73
- }},
74
- },
75
- },
76
- },
77
- },
78
- {
79
- Name : "variable-validation" ,
80
- Files : map [string ]string {
81
- "main.tf" : `variable "A" {
82
- validation {
83
- condition = var.A == "value"
84
- }
85
- }` ,
86
- },
87
- Response : & proto.Parse_Response {
88
- Type : & proto.Parse_Response_Complete {
89
- Complete : & proto.Parse_Complete {
90
- ParameterSchemas : []* proto.ParameterSchema {{
91
- Name : "A" ,
92
- RedisplayValue : true ,
93
- ValidationCondition : `var.A == "value"` ,
94
- ValidationTypeSystem : proto .ParameterSchema_HCL ,
95
- AllowOverrideSource : true ,
96
- DefaultDestination : & proto.ParameterDestination {
97
- Scheme : proto .ParameterDestination_PROVISIONER_VARIABLE ,
98
- },
99
- }},
100
- },
101
- },
102
- },
103
- },
104
- {
105
- Name : "bad-syntax" ,
106
- Files : map [string ]string {
107
- "main.tf" : "a;sd;ajsd;lajsd;lasjdf;a" ,
108
- },
109
- ErrorContains : `The ";" character is not valid.` ,
110
- },
111
- {
112
- Name : "multiple-variables" ,
113
- Files : map [string ]string {
114
- "main1.tf" : `variable "foo" { }
115
- variable "bar" { }` ,
116
- "main2.tf" : `variable "baz" { }
117
- variable "quux" { }` ,
118
- },
119
- Response : & proto.Parse_Response {
120
- Type : & proto.Parse_Response_Complete {
121
- Complete : & proto.Parse_Complete {
122
- ParameterSchemas : []* proto.ParameterSchema {
123
- {
124
- Name : "foo" ,
125
- RedisplayValue : true ,
126
- AllowOverrideSource : true ,
127
- Description : "" ,
128
- DefaultDestination : & proto.ParameterDestination {
129
- Scheme : proto .ParameterDestination_PROVISIONER_VARIABLE ,
130
- },
131
- },
132
- {
133
- Name : "bar" ,
134
- RedisplayValue : true ,
135
- AllowOverrideSource : true ,
136
- Description : "" ,
137
- DefaultDestination : & proto.ParameterDestination {
138
- Scheme : proto .ParameterDestination_PROVISIONER_VARIABLE ,
139
- },
140
- },
141
- {
142
- Name : "baz" ,
143
- RedisplayValue : true ,
144
- AllowOverrideSource : true ,
145
- Description : "" ,
146
- DefaultDestination : & proto.ParameterDestination {
147
- Scheme : proto .ParameterDestination_PROVISIONER_VARIABLE ,
148
- },
149
- },
150
- {
151
- Name : "quux" ,
152
- RedisplayValue : true ,
153
- AllowOverrideSource : true ,
154
- Description : "" ,
155
- DefaultDestination : & proto.ParameterDestination {
156
- Scheme : proto .ParameterDestination_PROVISIONER_VARIABLE ,
157
- },
158
- },
159
- },
160
- },
161
- },
162
- },
188
+ ErrorContains : "blah" ,
163
189
},
164
190
}
165
191
0 commit comments