github.com/terramate-io/tf@v0.0.0-20230830114523-fce866b4dfcd/legacy/terraform/ui_output_mock.go (about)

     1  // Copyright (c) HashiCorp, Inc.
     2  // SPDX-License-Identifier: MPL-2.0
     3  
     4  package terraform
     5  
     6  import "sync"
     7  
     8  // MockUIOutput is an implementation of UIOutput that can be used for tests.
     9  type MockUIOutput struct {
    10  	sync.Mutex
    11  	OutputCalled  bool
    12  	OutputMessage string
    13  	OutputFn      func(string)
    14  }
    15  
    16  func (o *MockUIOutput) Output(v string) {
    17  	o.Lock()
    18  	defer o.Unlock()
    19  	o.OutputCalled = true
    20  	o.OutputMessage = v
    21  	if o.OutputFn != nil {
    22  		o.OutputFn(v)
    23  	}
    24  }