554f1e6fee
* Protobuf Modernization Remove direct usage of golang/protobuf in favor of google.golang.org/protobuf Marshallers (protobuf and json) needed some changes to account for different APIs. Moved to using the google.golang.org/protobuf/types/known/* for the well known types including replacing some custom Struct manipulation with whats available in the structpb well known type package. This also updates our devtools script to install protoc-gen-go from the right location so that files it generates conform to the correct interfaces. * Fix go-mod-tidy make target to work on all modules
24 lines
561 B
Go
24 lines
561 B
Go
package structs_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/hashicorp/consul/agent/structs"
|
|
"github.com/hashicorp/consul/proto/pbpeering"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestEncodeDecodeProto(t *testing.T) {
|
|
arg := pbpeering.SecretsWriteRequest{
|
|
PeerID: "bbd26d02-a831-47b6-8a20-d16a99f56def",
|
|
}
|
|
buf, err := structs.EncodeProto(structs.PeeringSecretsWriteType, &arg)
|
|
require.NoError(t, err)
|
|
|
|
var out pbpeering.SecretsWriteRequest
|
|
|
|
err = structs.DecodeProto(buf[1:], &out)
|
|
require.NoError(t, err)
|
|
require.Equal(t, arg.PeerID, out.PeerID)
|
|
}
|