opentofu/command/ui_input_test.go
2019-03-08 10:24:40 +01:00

46 lines
788 B
Go

package command
import (
"bytes"
"context"
"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),
}
v, err := i.Input(context.Background(), &terraform.InputOpts{})
if err != nil {
t.Fatalf("err: %s", err)
}
if v != "foo" {
t.Fatalf("bad: %#v", v)
}
}
func TestUIInputInput_spaces(t *testing.T) {
i := &UIInput{
Reader: bytes.NewBufferString("foo bar\n"),
Writer: bytes.NewBuffer(nil),
}
v, err := i.Input(context.Background(), &terraform.InputOpts{})
if err != nil {
t.Fatalf("err: %s", err)
}
if v != "foo bar" {
t.Fatalf("bad: %#v", v)
}
}