]>
Commit | Line | Data |
---|---|---|
bae9f6d2 JC |
1 | package terraform |
2 | ||
107c1cdb ND |
3 | import "context" |
4 | ||
bae9f6d2 JC |
5 | // MockUIInput is an implementation of UIInput that can be used for tests. |
6 | type MockUIInput struct { | |
7 | InputCalled bool | |
8 | InputOpts *InputOpts | |
9 | InputReturnMap map[string]string | |
10 | InputReturnString string | |
11 | InputReturnError error | |
12 | InputFn func(*InputOpts) (string, error) | |
13 | } | |
14 | ||
107c1cdb | 15 | func (i *MockUIInput) Input(ctx context.Context, opts *InputOpts) (string, error) { |
bae9f6d2 JC |
16 | i.InputCalled = true |
17 | i.InputOpts = opts | |
18 | if i.InputFn != nil { | |
19 | return i.InputFn(opts) | |
20 | } | |
21 | if i.InputReturnMap != nil { | |
22 | return i.InputReturnMap[opts.Id], i.InputReturnError | |
23 | } | |
24 | return i.InputReturnString, i.InputReturnError | |
25 | } |