forked from hashicorp/terraform
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathui_input_test.go
49 lines (39 loc) · 849 Bytes
/
ui_input_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package plugin
import (
"reflect"
"testing"
"github.com/hashicorp/go-plugin"
"github.com/hashicorp/terraform/terraform"
)
func TestUIInput_impl(t *testing.T) {
var _ terraform.UIInput = new(UIInput)
}
func TestUIInput_input(t *testing.T) {
client, server := plugin.TestRPCConn(t)
defer client.Close()
i := new(terraform.MockUIInput)
i.InputReturnString = "foo"
err := server.RegisterName("Plugin", &UIInputServer{
UIInput: i,
})
if err != nil {
t.Fatalf("err: %s", err)
}
input := &UIInput{Client: client}
opts := &terraform.InputOpts{
Id: "foo",
}
v, err := input.Input(opts)
if !i.InputCalled {
t.Fatal("input should be called")
}
if !reflect.DeepEqual(i.InputOpts, opts) {
t.Fatalf("bad: %#v", i.InputOpts)
}
if err != nil {
t.Fatalf("bad: %#v", err)
}
if v != "foo" {
t.Fatalf("bad: %#v", v)
}
}