2024-02-08 03:48:59 -06:00
|
|
|
// Copyright (c) The OpenTofu Authors
|
|
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
// Copyright (c) 2023 HashiCorp, Inc.
|
2023-05-02 10:33:06 -05:00
|
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
|
2016-01-24 20:10:52 -06:00
|
|
|
package plugin
|
2014-10-04 11:11:51 -05:00
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2016-01-24 20:10:52 -06:00
|
|
|
"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) {
|
2016-01-24 20:10:52 -06:00
|
|
|
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
|
|
|
|
2016-01-24 20:10:52 -06:00
|
|
|
err := server.RegisterName("Plugin", &UIOutputServer{
|
2014-10-04 11:11:51 -05:00
|
|
|
UIOutput: o,
|
|
|
|
})
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("err: %s", err)
|
|
|
|
}
|
|
|
|
|
2016-01-24 20:10:52 -06:00
|
|
|
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)
|
|
|
|
}
|
|
|
|
}
|