Open IronSavior opened 4 years ago
Hi folks 👋
With the introduction of the terraform-plugin-testing module (migration guide), we are transferring feature requests relating to the helper/resource
"testing framework" in the terraform-plugin-sdk repository over to the new terraform-plugin-testing repository.
Thanks again for this feature request.
SDK version
Use-cases
I want to use verifying mocks in my provider unit tests while using the Terraform
resource.UnitTest()
test driver. The problem I'm facing occurs when my test mock receives an unexpected call and it responds by callingtesting.T.FailNow()
. Because the call toFailNow()
occurs on a different goroutine than the one started by the test, it deadlocks the test suite.Attempted Solutions
The best I can do has been wrapping the
testing.T
in a struct to overrideFailNow()
so it prints the name of the failing test and panics. I need a way to signal the test to shut down.Proposal
Provide a means to signal a running
resource.Test()
to shut down. For example, if I could pass in a cancelablecontext.Context
, then I could overrideFailNow()
so it triggers a cancellation that propagates into the test driver before invoking the realFailNow()
.References
https://github.com/golang/go/issues/15758 https://github.com/spacemeshos/go-spacemesh/issues/2151 https://github.com/golang/mock/issues/346