mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
Merge pull request #2923 from hashicorp/b-meta-lost-when-destroy-fails
helper/schema: record schema version when destroy fails
This commit is contained in:
commit
349008c29a
@ -119,7 +119,7 @@ func (r *Resource) Apply(
|
|||||||
if s.ID != "" {
|
if s.ID != "" {
|
||||||
// Destroy the resource since it is created
|
// Destroy the resource since it is created
|
||||||
if err := r.Delete(data, meta); err != nil {
|
if err := r.Delete(data, meta); err != nil {
|
||||||
return data.State(), err
|
return r.recordCurrentSchemaVersion(data.State()), err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure the ID is gone.
|
// Make sure the ID is gone.
|
||||||
|
@ -180,6 +180,7 @@ func TestResourceApply_destroyPartial(t *testing.T) {
|
|||||||
Optional: true,
|
Optional: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
SchemaVersion: 3,
|
||||||
}
|
}
|
||||||
|
|
||||||
r.Delete = func(d *ResourceData, m interface{}) error {
|
r.Delete = func(d *ResourceData, m interface{}) error {
|
||||||
@ -209,10 +210,13 @@ func TestResourceApply_destroyPartial(t *testing.T) {
|
|||||||
"id": "bar",
|
"id": "bar",
|
||||||
"foo": "42",
|
"foo": "42",
|
||||||
},
|
},
|
||||||
|
Meta: map[string]string{
|
||||||
|
"schema_version": "3",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
if !reflect.DeepEqual(actual, expected) {
|
if !reflect.DeepEqual(actual, expected) {
|
||||||
t.Fatalf("bad: %#v", actual)
|
t.Fatalf("expected:\n%#v\n\ngot:\n%#v", expected, actual)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user