2014-09-29 19:56:01 +02:00
|
|
|
package command
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
2019-03-07 21:07:13 +01:00
|
|
|
"context"
|
2014-09-29 19:56:01 +02:00
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/hashicorp/terraform/terraform"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestUIInput_impl(t *testing.T) {
|
|
|
|
var _ terraform.UIInput = new(UIInput)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestUIInputInput(t *testing.T) {
|
|
|
|
i := &UIInput{
|
|
|
|
Reader: bytes.NewBufferString("foo\n"),
|
|
|
|
Writer: bytes.NewBuffer(nil),
|
|
|
|
}
|
|
|
|
|
2019-03-07 21:07:13 +01:00
|
|
|
v, err := i.Input(context.Background(), &terraform.InputOpts{})
|
2014-09-29 19:56:01 +02:00
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("err: %s", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if v != "foo" {
|
|
|
|
t.Fatalf("bad: %#v", v)
|
|
|
|
}
|
|
|
|
}
|
2016-08-22 21:59:48 +02:00
|
|
|
|
|
|
|
func TestUIInputInput_spaces(t *testing.T) {
|
|
|
|
i := &UIInput{
|
|
|
|
Reader: bytes.NewBufferString("foo bar\n"),
|
|
|
|
Writer: bytes.NewBuffer(nil),
|
|
|
|
}
|
|
|
|
|
2019-03-07 21:07:13 +01:00
|
|
|
v, err := i.Input(context.Background(), &terraform.InputOpts{})
|
2016-08-22 21:59:48 +02:00
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("err: %s", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if v != "foo bar" {
|
|
|
|
t.Fatalf("bad: %#v", v)
|
|
|
|
}
|
|
|
|
}
|