github.com/turtlemonvh/terraform@v0.6.9-0.20151204001754-8e40b6b855e8/terraform/ui_input_mock.go (about)

     1  package terraform
     2  
     3  // MockUIInput is an implementation of UIInput that can be used for tests.
     4  type MockUIInput struct {
     5  	InputCalled       bool
     6  	InputOpts         *InputOpts
     7  	InputReturnMap    map[string]string
     8  	InputReturnString string
     9  	InputReturnError  error
    10  	InputFn           func(*InputOpts) (string, error)
    11  }
    12  
    13  func (i *MockUIInput) Input(opts *InputOpts) (string, error) {
    14  	i.InputCalled = true
    15  	i.InputOpts = opts
    16  	if i.InputFn != nil {
    17  		return i.InputFn(opts)
    18  	}
    19  	if i.InputReturnMap != nil {
    20  		return i.InputReturnMap[opts.Id], i.InputReturnError
    21  	}
    22  	return i.InputReturnString, i.InputReturnError
    23  }