From df38c2e3ead3c01517d2357815f72083db445837 Mon Sep 17 00:00:00 2001 From: James Bardin Date: Sat, 2 Dec 2017 22:33:53 -0500 Subject: [PATCH] make the mock provider stoppable The mock provider couldn't be stopped during diff, because the single mutex was held through the oepration. Release the mutex so Stop can be called. --- terraform/resource_provider_mock.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/terraform/resource_provider_mock.go b/terraform/resource_provider_mock.go index 73cde0ccb..9131f0f5f 100644 --- a/terraform/resource_provider_mock.go +++ b/terraform/resource_provider_mock.go @@ -196,13 +196,14 @@ func (p *MockResourceProvider) Diff( info *InstanceInfo, state *InstanceState, desired *ResourceConfig) (*InstanceDiff, error) { - p.Lock() - defer p.Unlock() + p.Lock() p.DiffCalled = true p.DiffInfo = info p.DiffState = state p.DiffDesired = desired + p.Unlock() + if p.DiffFn != nil { return p.DiffFn(info, state, desired) }