Use proto merge for merging proto based types

This commit is contained in:
Chris Roberts 2023-06-12 09:21:03 -07:00
parent dcb517e1fb
commit 1c98ab7111

View File

@ -14,6 +14,7 @@ import (
"github.com/imdario/mergo" "github.com/imdario/mergo"
"github.com/mitchellh/go-testing-interface" "github.com/mitchellh/go-testing-interface"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"google.golang.org/protobuf/proto"
"gorm.io/gorm" "gorm.io/gorm"
"gorm.io/gorm/logger" "gorm.io/gorm/logger"
) )
@ -165,8 +166,7 @@ func testRunnerProto(t testing.T, s *State, src *vagrant_server.Runner) *vagrant
func TestJobProto(t testing.T, src *vagrant_server.Job) *vagrant_server.Job { func TestJobProto(t testing.T, src *vagrant_server.Job) *vagrant_server.Job {
t.Helper() t.Helper()
require.NoError(t, mergo.Merge(src, dst := &vagrant_server.Job{
&vagrant_server.Job{
TargetRunner: &vagrant_server.Ref_Runner{ TargetRunner: &vagrant_server.Ref_Runner{
Target: &vagrant_server.Ref_Runner_Any{ Target: &vagrant_server.Ref_Runner_Any{
Any: &vagrant_server.Ref_RunnerAny{}, Any: &vagrant_server.Ref_RunnerAny{},
@ -180,10 +180,11 @@ func TestJobProto(t testing.T, src *vagrant_server.Job) *vagrant_server.Job {
Operation: &vagrant_server.Job_Noop_{ Operation: &vagrant_server.Job_Noop_{
Noop: &vagrant_server.Job_Noop{}, Noop: &vagrant_server.Job_Noop{},
}, },
}, }
))
return src proto.Merge(dst, src)
return dst
} }
func TestTempDir(t testing.T) string { func TestTempDir(t testing.T) string {