@@ -1121,7 +1121,7 @@ func TestApplyDestroy(t *testing.T) {
1121
1121
PlanApplyable : false ,
1122
1122
PlannedInputValues : make (map [string ]plans.DynamicValue ),
1123
1123
PlannedOutputValues : map [string ]cty.Value {
1124
- "value" : cty .DynamicVal ,
1124
+ "value" : cty .UnknownVal ( cty . String ) ,
1125
1125
},
1126
1126
PlannedCheckResults : & states.CheckResults {},
1127
1127
PlanTimestamp : fakePlanTimestamp ,
@@ -1256,7 +1256,7 @@ func TestApplyDestroy(t *testing.T) {
1256
1256
PlanApplyable : true ,
1257
1257
RequiredComponents : collections .NewSet (mustAbsComponent ("component.two" )),
1258
1258
PlannedOutputValues : map [string ]cty.Value {
1259
- "value" : cty .DynamicVal ,
1259
+ "value" : cty .StringVal ( "foo" ) ,
1260
1260
},
1261
1261
PlanTimestamp : fakePlanTimestamp ,
1262
1262
},
@@ -1268,7 +1268,7 @@ func TestApplyDestroy(t *testing.T) {
1268
1268
PlanApplyable : true ,
1269
1269
RequiredComponents : collections .NewSet (mustAbsComponent ("component.one" )),
1270
1270
PlannedOutputValues : map [string ]cty.Value {
1271
- "value" : cty .DynamicVal ,
1271
+ "value" : cty .StringVal ( "foo" ) ,
1272
1272
},
1273
1273
PlanTimestamp : fakePlanTimestamp ,
1274
1274
},
@@ -1319,6 +1319,129 @@ func TestApplyDestroy(t *testing.T) {
1319
1319
},
1320
1320
},
1321
1321
},
1322
+ "destroy-partial-state-with-module" : {
1323
+ path : "with-module" ,
1324
+ state : stackstate .NewStateBuilder ().
1325
+ AddComponentInstance (stackstate .NewComponentInstanceBuilder (mustAbsComponentInstance ("component.self" )).
1326
+ AddInputVariable ("id" , cty .StringVal ("self" )).
1327
+ AddInputVariable ("input" , cty .StringVal ("self" ))).
1328
+ AddResourceInstance (stackstate .NewResourceInstanceBuilder ().
1329
+ SetAddr (mustAbsResourceInstanceObject ("component.self.testing_resource.outside" )).
1330
+ SetProviderAddr (mustDefaultRootProvider ("testing" )).
1331
+ SetResourceInstanceObjectSrc (states.ResourceInstanceObjectSrc {
1332
+ AttrsJSON : mustMarshalJSONAttrs (map [string ]interface {}{
1333
+ "id" : "self" ,
1334
+ "value" : "self" ,
1335
+ }),
1336
+ Status : states .ObjectReady ,
1337
+ })).
1338
+ Build (),
1339
+ store : stacks_testing_provider .NewResourceStoreBuilder ().
1340
+ AddResource ("self" , cty .ObjectVal (map [string ]cty.Value {
1341
+ "id" : cty .StringVal ("self" ),
1342
+ "value" : cty .StringVal ("self" ),
1343
+ })).
1344
+ Build (),
1345
+ cycles : []TestCycle {
1346
+ {
1347
+ planMode : plans .DestroyMode ,
1348
+ planInputs : map [string ]cty.Value {
1349
+ "id" : cty .StringVal ("self" ),
1350
+ "input" : cty .StringVal ("self" ),
1351
+ },
1352
+ wantPlannedChanges : []stackplan.PlannedChange {
1353
+ & stackplan.PlannedChangeApplyable {
1354
+ Applyable : true ,
1355
+ },
1356
+ & stackplan.PlannedChangeComponentInstance {
1357
+ Addr : mustAbsComponentInstance ("component.self" ),
1358
+ Action : plans .Delete ,
1359
+ Mode : plans .DestroyMode ,
1360
+ PlanApplyable : true ,
1361
+ PlanComplete : true ,
1362
+ PlannedInputValues : map [string ]plans.DynamicValue {
1363
+ "create" : mustPlanDynamicValueDynamicType (cty .True ),
1364
+ "id" : mustPlanDynamicValueDynamicType (cty .StringVal ("self" )),
1365
+ "input" : mustPlanDynamicValueDynamicType (cty .StringVal ("self" )),
1366
+ },
1367
+ PlannedInputValueMarks : map [string ][]cty.PathValueMarks {
1368
+ "create" : nil ,
1369
+ "id" : nil ,
1370
+ "input" : nil ,
1371
+ },
1372
+ PlannedOutputValues : make (map [string ]cty.Value ),
1373
+ PlannedCheckResults : new (states.CheckResults ),
1374
+ PlanTimestamp : fakePlanTimestamp ,
1375
+ },
1376
+ & stackplan.PlannedChangeResourceInstancePlanned {
1377
+ ResourceInstanceObjectAddr : mustAbsResourceInstanceObject ("component.self.testing_resource.outside" ),
1378
+ ChangeSrc : & plans.ResourceInstanceChangeSrc {
1379
+ Addr : mustAbsResourceInstance ("testing_resource.outside" ),
1380
+ PrevRunAddr : mustAbsResourceInstance ("testing_resource.outside" ),
1381
+ ProviderAddr : mustDefaultRootProvider ("testing" ),
1382
+ ChangeSrc : plans.ChangeSrc {
1383
+ Action : plans .Delete ,
1384
+ Before : mustPlanDynamicValue (cty .ObjectVal (map [string ]cty.Value {
1385
+ "id" : cty .StringVal ("self" ),
1386
+ "value" : cty .StringVal ("self" ),
1387
+ })),
1388
+ After : mustPlanDynamicValue (cty .NullVal (cty .Object (map [string ]cty.Type {
1389
+ "id" : cty .String ,
1390
+ "value" : cty .String ,
1391
+ }))),
1392
+ },
1393
+ },
1394
+ PriorStateSrc : & states.ResourceInstanceObjectSrc {
1395
+ AttrsJSON : mustMarshalJSONAttrs (map [string ]interface {}{
1396
+ "id" : "self" ,
1397
+ "value" : "self" ,
1398
+ }),
1399
+ Status : states .ObjectReady ,
1400
+ Dependencies : make ([]addrs.ConfigResource , 0 ),
1401
+ },
1402
+ ProviderConfigAddr : mustDefaultRootProvider ("testing" ),
1403
+ Schema : stacks_testing_provider .TestingResourceSchema ,
1404
+ },
1405
+ & stackplan.PlannedChangeHeader {
1406
+ TerraformVersion : version .SemVer ,
1407
+ },
1408
+ & stackplan.PlannedChangePlannedTimestamp {
1409
+ PlannedTimestamp : fakePlanTimestamp ,
1410
+ },
1411
+ & stackplan.PlannedChangeRootInputValue {
1412
+ Addr : mustStackInputVariable ("id" ),
1413
+ Action : plans .Create ,
1414
+ Before : cty .NullVal (cty .DynamicPseudoType ),
1415
+ After : cty .StringVal ("self" ),
1416
+ DeleteOnApply : true ,
1417
+ },
1418
+ & stackplan.PlannedChangeRootInputValue {
1419
+ Addr : mustStackInputVariable ("input" ),
1420
+ Action : plans .Create ,
1421
+ Before : cty .NullVal (cty .DynamicPseudoType ),
1422
+ After : cty .StringVal ("self" ),
1423
+ DeleteOnApply : true ,
1424
+ },
1425
+ },
1426
+ wantAppliedChanges : []stackstate.AppliedChange {
1427
+ & stackstate.AppliedChangeComponentInstanceRemoved {
1428
+ ComponentAddr : mustAbsComponent ("component.self" ),
1429
+ ComponentInstanceAddr : mustAbsComponentInstance ("component.self" ),
1430
+ },
1431
+ & stackstate.AppliedChangeResourceInstanceObject {
1432
+ ResourceInstanceObjectAddr : mustAbsResourceInstanceObject ("component.self.testing_resource.outside" ),
1433
+ ProviderConfigAddr : mustDefaultRootProvider ("testing" ),
1434
+ },
1435
+ & stackstate.AppliedChangeInputVariable {
1436
+ Addr : mustStackInputVariable ("id" ),
1437
+ },
1438
+ & stackstate.AppliedChangeInputVariable {
1439
+ Addr : mustStackInputVariable ("input" ),
1440
+ },
1441
+ },
1442
+ },
1443
+ },
1444
+ },
1322
1445
"destroy-partial-state" : {
1323
1446
path : "destroy-partial-state" ,
1324
1447
state : stackstate .NewStateBuilder ().
@@ -1379,7 +1502,7 @@ func TestApplyDestroy(t *testing.T) {
1379
1502
PlanComplete : true ,
1380
1503
PlannedInputValues : make (map [string ]plans.DynamicValue ),
1381
1504
PlannedOutputValues : map [string ]cty.Value {
1382
- "deleted_id" : cty .DynamicVal ,
1505
+ "deleted_id" : cty .UnknownVal ( cty . String ) ,
1383
1506
},
1384
1507
PlannedCheckResults : & states.CheckResults {},
1385
1508
PlanTimestamp : fakePlanTimestamp ,
0 commit comments