Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cancelable resource.Test() / UnitTest() #66

Open
IronSavior opened this issue Nov 5, 2020 · 1 comment
Open

Cancelable resource.Test() / UnitTest() #66

IronSavior opened this issue Nov 5, 2020 · 1 comment
Labels
enhancement New feature or request

Comments

@IronSavior
Copy link

IronSavior commented Nov 5, 2020

SDK version

2.0.2

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 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().

References

golang/go#15758
spacemeshos/go-spacemesh#2151
golang/mock#346

@bflad
Copy link
Contributor

bflad commented Feb 28, 2023

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.

@bflad bflad transferred this issue from hashicorp/terraform-plugin-sdk Feb 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants