mirror of
https://github.com/opentofu/opentofu.git
synced 2025-01-11 00:22:32 -06:00
cb2e9119aa
Signed-off-by: namgyalangmo <75657887+namgyalangmo@users.noreply.github.com>
31 lines
794 B
Go
31 lines
794 B
Go
// Copyright (c) The OpenTofu Authors
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
// Copyright (c) 2023 HashiCorp, Inc.
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
package tofu
|
|
|
|
import "context"
|
|
|
|
// MockUIInput is an implementation of UIInput that can be used for tests.
|
|
type MockUIInput struct {
|
|
InputCalled bool
|
|
InputOpts *InputOpts
|
|
InputReturnMap map[string]string
|
|
InputReturnString string
|
|
InputReturnError error
|
|
InputFn func(*InputOpts) (string, error)
|
|
}
|
|
|
|
func (i *MockUIInput) Input(ctx context.Context, opts *InputOpts) (string, error) {
|
|
i.InputCalled = true
|
|
i.InputOpts = opts
|
|
if i.InputFn != nil {
|
|
return i.InputFn(opts)
|
|
}
|
|
if i.InputReturnMap != nil {
|
|
return i.InputReturnMap[opts.Id], i.InputReturnError
|
|
}
|
|
return i.InputReturnString, i.InputReturnError
|
|
}
|