2023-03-28 18:39:22 +00:00
|
|
|
// Copyright (c) HashiCorp, Inc.
|
|
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
|
2023-01-11 14:39:10 +00:00
|
|
|
package structs_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/hashicorp/consul/agent/structs"
|
2023-02-17 21:14:46 +00:00
|
|
|
"github.com/hashicorp/consul/proto/private/pbpeering"
|
2023-01-11 14:39:10 +00:00
|
|
|
"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)
|
|
|
|
}
|