Test expected delete

This commit is contained in:
Fraser Waters 2021-11-04 15:51:46 +00:00
parent 505e4c5d06
commit d995901fa7
2 changed files with 10 additions and 3 deletions

View file

@ -97,8 +97,15 @@ func (rp *ResourcePlan) diffPropertyDependencies(a, b map[resource.PropertyKey][
}
func (rp *ResourcePlan) checkGoal(programGoal *resource.Goal) error {
contract.Assert(rp.Goal.Type == programGoal.Type)
contract.Assert(rp.Goal.Name == programGoal.Name)
contract.Assert(programGoal != nil)
// rp.Goal may be nil, but if it isn't Type and Name should match
contract.Assert(rp.Goal == nil || rp.Goal.Type == programGoal.Type)
contract.Assert(rp.Goal == nil || rp.Goal.Name == programGoal.Name)
if rp.Goal == nil {
// If the plan goal is nil it expected a delete
return fmt.Errorf("resource unexpectedly not deleted")
}
// Check that either both resources are custom resources or both are component resources.
if programGoal.Custom != rp.Goal.Custom {

View file

@ -241,7 +241,7 @@ func (sg *stepGenerator) generateSteps(event RegisterResourceEvent) ([]Step, res
sg.urns[urn] = true
// If there is a plan for this resource, validate that the program goal conforms to the plan.
if len(sg.deployment.plan) != 0 {
if sg.deployment.plan != nil {
resourcePlan, ok := sg.deployment.plan[urn]
if !ok {
return nil, result.Errorf("resource not found in plan")