Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion helper/schema/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 5 additions & 1 deletion helper/schema/resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ func TestResourceApply_destroyPartial(t *testing.T) {
Optional: true,
},
},
SchemaVersion: 3,
}

r.Delete = func(d *ResourceData, m interface{}) error {
Expand Down Expand Up @@ -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)
}
}

Expand Down