You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 calling testing.T.FailNow(). Because the call to FailNow() 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 override FailNow() 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 cancelable context.Context, then I could override FailNow() so it triggers a cancellation that propagates into the test driver before invoking the real FailNow().
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
golang/go#15758
spacemeshos/go-spacemesh#2151
golang/mock#346
The text was updated successfully, but these errors were encountered: