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{}) {
// Get the stop channel. runContext might be nil only during tests.
// If this is called during a proper run operation, this will never
// be nil.
var stopCh <-chan struct{}
if ctx := c.runContext; ctx != nil {
stopCh = ctx.Done()
}
// Get the stop channel. runContext will never be nil since this should
// only be called within the context of an operation started with
// acquireRun
stopCh := c.runContext.Done()
// Wait for a stop or completion
select {

View File

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