github.com/sl1pm4t/terraform@v0.6.4-0.20170725213156-870617d22df3/plugin/ui_output_test.go (about)

     1  package plugin
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/hashicorp/go-plugin"
     7  	"github.com/hashicorp/terraform/terraform"
     8  )
     9  
    10  func TestUIOutput_impl(t *testing.T) {
    11  	var _ terraform.UIOutput = new(UIOutput)
    12  }
    13  
    14  func TestUIOutput_input(t *testing.T) {
    15  	client, server := plugin.TestRPCConn(t)
    16  	defer client.Close()
    17  
    18  	o := new(terraform.MockUIOutput)
    19  
    20  	err := server.RegisterName("Plugin", &UIOutputServer{
    21  		UIOutput: o,
    22  	})
    23  	if err != nil {
    24  		t.Fatalf("err: %s", err)
    25  	}
    26  
    27  	output := &UIOutput{Client: client}
    28  	output.Output("foo")
    29  	if !o.OutputCalled {
    30  		t.Fatal("output should be called")
    31  	}
    32  	if o.OutputMessage != "foo" {
    33  		t.Fatalf("bad: %#v", o.OutputMessage)
    34  	}
    35  }