terraform: acquireRun during test to avoid special case logic

This commit is contained in:
Mitchell Hashimoto 2017-01-30 08:41:38 -08:00
parent 5b42781117
commit 00232f0994
No known key found for this signature in database
GPG Key ID: 744E147AA52F5B0A
2 changed files with 5 additions and 7 deletions

View File

@ -907,13 +907,10 @@ func (c *Context) walk(
} }
func (c *Context) watchStop(walker *ContextGraphWalker, doneCh <-chan struct{}) { func (c *Context) watchStop(walker *ContextGraphWalker, doneCh <-chan struct{}) {
// Get the stop channel. runContext might be nil only during tests. // Get the stop channel. runContext will never be nil since this should
// If this is called during a proper run operation, this will never // only be called within the context of an operation started with
// be nil. // acquireRun
var stopCh <-chan struct{} stopCh := c.runContext.Done()
if ctx := c.runContext; ctx != nil {
stopCh = ctx.Done()
}
// Wait for a stop or completion // Wait for a stop or completion
select { select {

View File

@ -906,6 +906,7 @@ func TestContext2Validate_PlanGraphBuilder(t *testing.T) {
Targets: c.targets, Targets: c.targets,
}).Build(RootModulePath) }).Build(RootModulePath)
defer c.acquireRun("validate-test")()
walker, err := c.walk(graph, graph, walkValidate) walker, err := c.walk(graph, graph, walkValidate)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)