consul/internal/resource/resourcetest/decode.go

24 lines
512 B
Go

// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: BUSL-1.1
package resourcetest
import (
"testing"
"github.com/stretchr/testify/require"
"google.golang.org/protobuf/proto"
"github.com/hashicorp/consul/internal/resource"
"github.com/hashicorp/consul/proto-public/pbresource"
)
func MustDecode[V any, PV interface {
proto.Message
*V
}](t *testing.T, res *pbresource.Resource) *resource.DecodedResource[V, PV] {
dec, err := resource.Decode[V, PV](res)
require.NoError(t, err)
return dec
}