github.com/paultyng/terraform@v0.6.11-0.20180227224804-66ff8f8bed40/command/ui_input_test.go (about)

     1  package command
     2  
     3  import (
     4  	"bytes"
     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 TestUIInputInput(t *testing.T) {
    15  	i := &UIInput{
    16  		Reader: bytes.NewBufferString("foo\n"),
    17  		Writer: bytes.NewBuffer(nil),
    18  	}
    19  
    20  	v, err := i.Input(&terraform.InputOpts{})
    21  	if err != nil {
    22  		t.Fatalf("err: %s", err)
    23  	}
    24  
    25  	if v != "foo" {
    26  		t.Fatalf("bad: %#v", v)
    27  	}
    28  }
    29  
    30  func TestUIInputInput_spaces(t *testing.T) {
    31  	i := &UIInput{
    32  		Reader: bytes.NewBufferString("foo bar\n"),
    33  		Writer: bytes.NewBuffer(nil),
    34  	}
    35  
    36  	v, err := i.Input(&terraform.InputOpts{})
    37  	if err != nil {
    38  		t.Fatalf("err: %s", err)
    39  	}
    40  
    41  	if v != "foo bar" {
    42  		t.Fatalf("bad: %#v", v)
    43  	}
    44  }