github.com/blend/go-sdk@v1.20220411.3/reflectutil/patch_test.go (about) 1 /* 2 3 Copyright (c) 2022 - Present. Blend Labs, Inc. All rights reserved 4 Use of this source code is governed by a MIT license that can be found in the LICENSE file. 5 6 */ 7 8 package reflectutil 9 10 import ( 11 "testing" 12 13 "github.com/blend/go-sdk/assert" 14 ) 15 16 func TestPatch(t *testing.T) { 17 assert := assert.New(t) 18 19 myObj := testType{} 20 myObj.ID = 123 21 myObj.Name = "Test Object" 22 myObj.NotTagged = "Not Tagged" 23 myObj.Tagged = "Is Tagged" 24 myObj.SubTypes = append([]subType{}, subType{1, "One"}) 25 myObj.SubTypes = append(myObj.SubTypes, subType{2, "Two"}) 26 myObj.SubTypes = append(myObj.SubTypes, subType{3, "Three"}) 27 myObj.SubTypes = append(myObj.SubTypes, subType{4, "Four"}) 28 29 patchData := make(map[string]interface{}) 30 patchData["Tagged"] = "Is Not Tagged" 31 32 err := Patch(&myObj, patchData) 33 assert.Nil(err) 34 assert.Equal("Is Not Tagged", myObj.Tagged) 35 }