Merge pull request from hashicorp/b-meta-lost-when-destroy-fails

helper/schema: record schema version when destroy fails
This commit is contained in:
Paul Hinze 2015-08-03 15:58:50 -05:00
commit 349008c29a
2 changed files with 6 additions and 2 deletions

View File

@ -119,7 +119,7 @@ func (r *Resource) Apply(
if s.ID != "" {
// Destroy the resource since it is created
if err := r.Delete(data, meta); err != nil {
return data.State(), err
return r.recordCurrentSchemaVersion(data.State()), err
}
// Make sure the ID is gone.

View File

@ -180,6 +180,7 @@ func TestResourceApply_destroyPartial(t *testing.T) {
Optional: true,
},
},
SchemaVersion: 3,
}
r.Delete = func(d *ResourceData, m interface{}) error {
@ -209,10 +210,13 @@ func TestResourceApply_destroyPartial(t *testing.T) {
"id": "bar",
"foo": "42",
},
Meta: map[string]string{
"schema_version": "3",
},
}
if !reflect.DeepEqual(actual, expected) {
t.Fatalf("bad: %#v", actual)
t.Fatalf("expected:\n%#v\n\ngot:\n%#v", expected, actual)
}
}