@@ -34,7 +34,7 @@ func TestContext2Apply_actions(t *testing.T) {
34
34
"unreferenced" : {
35
35
module : map [string ]string {
36
36
"main.tf" : `
37
- action "test_unlinked " "hello" {}
37
+ action "act_unlinked " "hello" {}
38
38
` ,
39
39
},
40
40
expectInvokeActionCalled : false ,
@@ -43,12 +43,12 @@ action "test_unlinked" "hello" {}
43
43
"before_create triggered" : {
44
44
module : map [string ]string {
45
45
"main.tf" : `
46
- action "test_unlinked " "hello" {}
46
+ action "act_unlinked " "hello" {}
47
47
resource "test_object" "a" {
48
48
lifecycle {
49
49
action_trigger {
50
50
events = [before_create]
51
- actions = [action.test_unlinked .hello]
51
+ actions = [action.act_unlinked .hello]
52
52
}
53
53
}
54
54
}
@@ -60,12 +60,12 @@ resource "test_object" "a" {
60
60
"after_create triggered" : {
61
61
module : map [string ]string {
62
62
"main.tf" : `
63
- action "test_unlinked " "hello" {}
63
+ action "act_unlinked " "hello" {}
64
64
resource "test_object" "a" {
65
65
lifecycle {
66
66
action_trigger {
67
67
events = [after_create]
68
- actions = [action.test_unlinked .hello]
68
+ actions = [action.act_unlinked .hello]
69
69
}
70
70
}
71
71
}
@@ -77,13 +77,13 @@ resource "test_object" "a" {
77
77
"before_update triggered" : {
78
78
module : map [string ]string {
79
79
"main.tf" : `
80
- action "test_unlinked " "hello" {}
80
+ action "act_unlinked " "hello" {}
81
81
resource "test_object" "a" {
82
82
name = "new name"
83
83
lifecycle {
84
84
action_trigger {
85
85
events = [before_update]
86
- actions = [action.test_unlinked .hello]
86
+ actions = [action.act_unlinked .hello]
87
87
}
88
88
}
89
89
}
@@ -112,13 +112,13 @@ resource "test_object" "a" {
112
112
"after_update triggered" : {
113
113
module : map [string ]string {
114
114
"main.tf" : `
115
- action "test_unlinked " "hello" {}
115
+ action "act_unlinked " "hello" {}
116
116
resource "test_object" "a" {
117
117
name = "new name"
118
118
lifecycle {
119
119
action_trigger {
120
120
events = [after_update]
121
- actions = [action.test_unlinked .hello]
121
+ actions = [action.act_unlinked .hello]
122
122
}
123
123
}
124
124
}
@@ -147,12 +147,12 @@ resource "test_object" "a" {
147
147
"before_create failing" : {
148
148
module : map [string ]string {
149
149
"main.tf" : `
150
- action "test_unlinked " "hello" {}
150
+ action "act_unlinked " "hello" {}
151
151
resource "test_object" "a" {
152
152
lifecycle {
153
153
action_trigger {
154
154
events = [before_create]
155
- actions = [action.test_unlinked .hello]
155
+ actions = [action.act_unlinked .hello]
156
156
}
157
157
}
158
158
}
@@ -183,12 +183,12 @@ resource "test_object" "a" {
183
183
"before_create failing to call invoke" : {
184
184
module : map [string ]string {
185
185
"main.tf" : `
186
- action "test_unlinked " "hello" {}
186
+ action "act_unlinked " "hello" {}
187
187
resource "test_object" "a" {
188
188
lifecycle {
189
189
action_trigger {
190
190
events = [before_create]
191
- actions = [action.test_unlinked .hello]
191
+ actions = [action.act_unlinked .hello]
192
192
}
193
193
}
194
194
}
@@ -217,7 +217,7 @@ resource "test_object" "a" {
217
217
resource "test_object" "a" {
218
218
name = "foo"
219
219
}
220
- action "test_unlinked " "hello" {
220
+ action "act_unlinked " "hello" {
221
221
config {
222
222
attr = resource.test_object.a.name
223
223
}
@@ -226,15 +226,15 @@ resource "test_object" "b" {
226
226
lifecycle {
227
227
action_trigger {
228
228
events = [before_create]
229
- actions = [action.test_unlinked .hello]
229
+ actions = [action.act_unlinked .hello]
230
230
}
231
231
}
232
232
}
233
233
` ,
234
234
},
235
235
expectInvokeActionCalled : true ,
236
236
expectInvokeActionCalls : []providers.InvokeActionRequest {{
237
- ActionType : "test_unlinked " ,
237
+ ActionType : "act_unlinked " ,
238
238
PlannedActionData : cty .ObjectVal (map [string ]cty.Value {
239
239
"attr" : cty .StringVal ("foo" ),
240
240
}),
@@ -248,7 +248,7 @@ resource "test_object" "b" {
248
248
variable "unknown_value" {
249
249
type = string
250
250
}
251
- action "test_unlinked " "hello" {
251
+ action "act_unlinked " "hello" {
252
252
config {
253
253
attr = var.unknown_value
254
254
}
@@ -257,7 +257,7 @@ resource "test_object" "b" {
257
257
lifecycle {
258
258
action_trigger {
259
259
events = [before_create]
260
- actions = [action.test_unlinked .hello]
260
+ actions = [action.act_unlinked .hello]
261
261
}
262
262
}
263
263
}
@@ -271,7 +271,7 @@ resource "test_object" "b" {
271
271
272
272
expectInvokeActionCalled : true ,
273
273
expectInvokeActionCalls : []providers.InvokeActionRequest {{
274
- ActionType : "test_unlinked " ,
274
+ ActionType : "act_unlinked " ,
275
275
PlannedActionData : cty .ObjectVal (map [string ]cty.Value {
276
276
"attr" : cty .UnknownVal (cty .String ),
277
277
}),
@@ -285,7 +285,7 @@ variable "secret_value" {
285
285
type = string
286
286
sensitive = true
287
287
}
288
- action "test_unlinked " "hello" {
288
+ action "act_unlinked " "hello" {
289
289
config {
290
290
attr = var.secret_value
291
291
}
@@ -294,7 +294,7 @@ resource "test_object" "b" {
294
294
lifecycle {
295
295
action_trigger {
296
296
events = [before_create]
297
- actions = [action.test_unlinked .hello]
297
+ actions = [action.act_unlinked .hello]
298
298
}
299
299
}
300
300
}
@@ -308,7 +308,7 @@ resource "test_object" "b" {
308
308
309
309
expectInvokeActionCalled : true ,
310
310
expectInvokeActionCalls : []providers.InvokeActionRequest {{
311
- ActionType : "test_unlinked " ,
311
+ ActionType : "act_unlinked " ,
312
312
PlannedActionData : cty .ObjectVal (map [string ]cty.Value {
313
313
"attr" : cty .StringVal ("psst, I'm secret" ),
314
314
}),
@@ -320,34 +320,40 @@ resource "test_object" "b" {
320
320
321
321
invokeActionCalls := []providers.InvokeActionRequest {}
322
322
323
- p := & testing_provider.MockProvider {
323
+ testProvider := & testing_provider.MockProvider {
324
324
GetProviderSchemaResponse : & providers.GetProviderSchemaResponse {
325
- Actions : map [string ]providers.ActionSchema {
326
- "test_unlinked " : {
327
- ConfigSchema : & configschema.Block {
325
+ ResourceTypes : map [string ]providers.Schema {
326
+ "test_object " : {
327
+ Body : & configschema.Block {
328
328
Attributes : map [string ]* configschema.Attribute {
329
- "attr " : {
329
+ "name " : {
330
330
Type : cty .String ,
331
331
Optional : true ,
332
332
},
333
333
},
334
334
},
335
-
336
- Unlinked : & providers.UnlinkedAction {},
337
335
},
338
336
},
339
- ResourceTypes : map [string ]providers.Schema {
340
- "test_object" : {
341
- Body : & configschema.Block {
337
+ },
338
+ }
339
+
340
+ actionProvider := & testing_provider.MockProvider {
341
+ GetProviderSchemaResponse : & providers.GetProviderSchemaResponse {
342
+ Actions : map [string ]providers.ActionSchema {
343
+ "act_unlinked" : {
344
+ ConfigSchema : & configschema.Block {
342
345
Attributes : map [string ]* configschema.Attribute {
343
- "name " : {
346
+ "attr " : {
344
347
Type : cty .String ,
345
348
Optional : true ,
346
349
},
347
350
},
348
351
},
352
+
353
+ Unlinked : & providers.UnlinkedAction {},
349
354
},
350
355
},
356
+ ResourceTypes : map [string ]providers.Schema {},
351
357
},
352
358
InvokeActionFn : func (req providers.InvokeActionRequest ) providers.InvokeActionResponse {
353
359
invokeActionCalls = append (invokeActionCalls , req )
@@ -383,9 +389,8 @@ resource "test_object" "b" {
383
389
384
390
ctx := testContext2 (t , & ContextOpts {
385
391
Providers : map [addrs.Provider ]providers.Factory {
386
- // The providers never actually going to get called here, we should
387
- // catch the error long before anything happens.
388
- addrs .NewDefaultProvider ("test" ): testProviderFuncFixed (p ),
392
+ addrs .NewDefaultProvider ("test" ): testProviderFuncFixed (testProvider ),
393
+ addrs .NewDefaultProvider ("act" ): testProviderFuncFixed (actionProvider ),
389
394
},
390
395
})
391
396
0 commit comments