opentofu/internal/plugin/ui_output_test.go

39 lines
722 B
Go
Raw Normal View History

// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package plugin
2014-10-04 11:11:51 -05:00
import (
"testing"
"github.com/hashicorp/go-plugin"
2023-09-20 07:16:53 -05:00
"github.com/opentofu/opentofu/internal/tofu"
2014-10-04 11:11:51 -05:00
)
func TestUIOutput_impl(t *testing.T) {
2023-09-20 07:16:53 -05:00
var _ tofu.UIOutput = new(UIOutput)
2014-10-04 11:11:51 -05:00
}
func TestUIOutput_input(t *testing.T) {
client, server := plugin.TestRPCConn(t)
2014-10-04 11:11:51 -05:00
defer client.Close()
2023-09-20 07:16:53 -05:00
o := new(tofu.MockUIOutput)
2014-10-04 11:11:51 -05:00
err := server.RegisterName("Plugin", &UIOutputServer{
2014-10-04 11:11:51 -05:00
UIOutput: o,
})
if err != nil {
t.Fatalf("err: %s", err)
}
output := &UIOutput{Client: client}
2014-10-04 11:11:51 -05:00
output.Output("foo")
if !o.OutputCalled {
t.Fatal("output should be called")
}
if o.OutputMessage != "foo" {
t.Fatalf("bad: %#v", o.OutputMessage)
}
}