2023-08-01 18:39:15 +00:00
|
|
|
// Copyright (c) HashiCorp, Inc.
|
2023-08-11 13:12:13 +00:00
|
|
|
// SPDX-License-Identifier: BUSL-1.1
|
2023-08-01 18:39:15 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
}
|