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