terraform/plugin/ui_input_test.go

51 lines
882 B
Go
Raw Normal View History

package plugin
2014-09-29 09:23:17 +02:00
import (
"context"
2014-09-29 09:23:17 +02:00
"reflect"
"testing"
"github.com/hashicorp/go-plugin"
2014-09-29 09:23:17 +02:00
"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)
2014-09-29 09:23:17 +02:00
defer client.Close()
i := new(terraform.MockUIInput)
i.InputReturnString = "foo"
err := server.RegisterName("Plugin", &UIInputServer{
2014-09-29 09:23:17 +02:00
UIInput: i,
})
if err != nil {
t.Fatalf("err: %s", err)
}
input := &UIInput{Client: client}
2014-09-29 09:23:17 +02:00
opts := &terraform.InputOpts{
Id: "foo",
}
v, err := input.Input(context.Background(), opts)
2014-09-29 09:23:17 +02:00
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)
}
}