mirror of
https://git.uploadfilter24.eu/lerentis/terraform-provider-gitea.git
synced 2024-09-06 05:19:01 +00:00
26 lines
650 B
Go
26 lines
650 B
Go
|
package terraform
|
||
|
|
||
|
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
|
||
|
}
|