How to test blocked destroys in a custom provider?

Hello, I’m working on a custom Terraform provider and I’m adding a “force_destroy” or “force_delete” flag (not sure which name I’ll use, the first feels a bit more idiomatic).

I have some resources that can only be deleted when this flag is set to true (defaults to false) however I’m not sure how to add an acceptance test to confirm that the destroys are in fact blocked and return an error. I don’t see a hook in the SDK to detect when a destroy runs and fails.

The CheckDestroy test check function only seems to work in the context of the destroy phase actually running to completion.

Any help is appreciated, thank you in advance.

This doesn’t seem possible per ExpectError is ignored for test case where destroy action expected to have error · Issue #609 · hashicorp/terraform-plugin-sdk · GitHub

I have a PR to make this work Add handling for destroy errors by matthewcummings · Pull Request #976 · hashicorp/terraform-plugin-sdk · GitHub