terraform: fix some diff comparison

This commit is contained in:
Mitchell Hashimoto 2015-02-13 14:03:17 -08:00
parent b8ebcc85d7
commit 119d5a09cf
3 changed files with 17 additions and 5 deletions

View File

@ -2735,7 +2735,6 @@ func TestContext2Apply_emptyModule(t *testing.T) {
}
}
/*
func TestContext2Apply_createBeforeDestroy(t *testing.T) {
m := testModule(t, "apply-good-create-before")
p := testProvider("aws")
@ -2789,7 +2788,6 @@ func TestContext2Apply_createBeforeDestroy(t *testing.T) {
t.Fatalf("bad: \n%s", actual)
}
}
*/
func TestContext2Apply_minimal(t *testing.T) {
m := testModule(t, "apply-minimal")
@ -3372,7 +3370,7 @@ func TestContext2Apply_provisionerFail(t *testing.T) {
}
/*
func TestContextApply_provisionerFail_createBeforeDestroy(t *testing.T) {
func TestContext2Apply_provisionerFail_createBeforeDestroy(t *testing.T) {
m := testModule(t, "apply-provisioner-fail-create-before")
p := testProvider("aws")
pr := testProvisioner()
@ -3400,7 +3398,7 @@ func TestContextApply_provisionerFail_createBeforeDestroy(t *testing.T) {
},
},
}
ctx := testContext(t, &ContextOpts{
ctx := testContext2(t, &ContextOpts{
Module: m,
Providers: map[string]ResourceProviderFactory{
"aws": testProviderFuncFixed(p),
@ -3427,6 +3425,7 @@ func TestContextApply_provisionerFail_createBeforeDestroy(t *testing.T) {
}
}
/*
func TestContextApply_error_createBeforeDestroy(t *testing.T) {
m := testModule(t, "apply-error-create-before")
p := testProvider("aws")

View File

@ -30,6 +30,18 @@ func (n *EvalCompareDiff) Eval(
two = new(InstanceDiff)
two.init()
}
oneId := one.Attributes["id"]
twoId := two.Attributes["id"]
delete(one.Attributes, "id")
delete(two.Attributes, "id")
defer func() {
if oneId != nil {
one.Attributes["id"] = oneId
}
if twoId != nil {
two.Attributes["id"] = twoId
}
}()
if !one.Same(two) {
log.Printf("[ERROR] %s: diff's didn't match", n.Info.Id)

View File

@ -241,10 +241,11 @@ func (n *graphNodeExpandedResource) EvalTree() EvalNode {
return true, EvalEarlyExitError{}
}
if diffApply.Destroy {
if diffApply.Destroy && len(diffApply.Attributes) == 0 {
return true, EvalEarlyExitError{}
}
diffApply.Destroy = false
return true, nil
},
Node: EvalNoop{},