opentofu/helper/plugin/diagnostics_test.go
James Bardin 63dcdbe948 helper/plugin package for grpc servers
The new helper/plugin package contains the grpc servers for handling the
new plugin protocol

The GRPCProviderServer and GRPCProvisionerServer handle the grpc plugin
protocol, and convert the requests to the legacy schema.Provider and
schema.Provisioner methods.
2018-10-16 18:58:49 -07:00

46 lines
719 B
Go

package plugin
import (
"errors"
"testing"
"github.com/google/go-cmp/cmp"
"github.com/hashicorp/terraform/plugin/proto"
)
func TestDiagnostics(t *testing.T) {
diags := diagsFromWarnsErrs(
[]string{
"warning 1",
"warning 2",
},
[]error{
errors.New("error 1"),
errors.New("error 2"),
},
)
expected := []*proto.Diagnostic{
{
Severity: proto.Diagnostic_WARNING,
Summary: "warning 1",
},
{
Severity: proto.Diagnostic_WARNING,
Summary: "warning 2",
},
{
Severity: proto.Diagnostic_ERROR,
Summary: "error 1",
},
{
Severity: proto.Diagnostic_ERROR,
Summary: "error 2",
},
}
if !cmp.Equal(expected, diags) {
t.Fatal(cmp.Diff(expected, diags))
}
}