github.com/machinefi/w3bstream@v1.6.5-rc9.0.20240426031326-b8c7c4876e72/pkg/test/patch_models/resource.go (about) 1 package patch_models 2 3 import ( 4 "reflect" 5 6 "github.com/agiledragon/gomonkey/v2" 7 8 "github.com/machinefi/w3bstream/pkg/depends/kit/sqlx" 9 "github.com/machinefi/w3bstream/pkg/models" 10 ) 11 12 var _targetModelResource = reflect.TypeOf(&models.Resource{}) 13 14 func ResourceFetchByResourceID(patch *gomonkey.Patches, overwrite *models.Resource, err error) *gomonkey.Patches { 15 return patch.ApplyMethod( 16 _targetModelResource, 17 "FetchByResourceID", 18 func(receiver *models.Resource, _ sqlx.DBExecutor) error { 19 if overwrite != nil { 20 *receiver = *overwrite 21 } 22 return err 23 }, 24 ) 25 }