github.com/mikesimons/terraform@v0.6.13-0.20160304043642-f11448c69214/rpc/ui_input_test.go (about) 1 package rpc 2 3 import ( 4 "reflect" 5 "testing" 6 7 "github.com/hashicorp/terraform/terraform" 8 ) 9 10 func TestUIInput_impl(t *testing.T) { 11 var _ terraform.UIInput = new(UIInput) 12 } 13 14 func TestUIInput_input(t *testing.T) { 15 client, server := testClientServer(t) 16 defer client.Close() 17 18 i := new(terraform.MockUIInput) 19 i.InputReturnString = "foo" 20 21 err := server.RegisterName("UIInput", &UIInputServer{ 22 UIInput: i, 23 }) 24 if err != nil { 25 t.Fatalf("err: %s", err) 26 } 27 28 input := &UIInput{Client: client, Name: "UIInput"} 29 30 opts := &terraform.InputOpts{ 31 Id: "foo", 32 } 33 34 v, err := input.Input(opts) 35 if !i.InputCalled { 36 t.Fatal("input should be called") 37 } 38 if !reflect.DeepEqual(i.InputOpts, opts) { 39 t.Fatalf("bad: %#v", i.InputOpts) 40 } 41 if err != nil { 42 t.Fatalf("bad: %#v", err) 43 } 44 45 if v != "foo" { 46 t.Fatalf("bad: %#v", v) 47 } 48 }