github.com/machinefi/w3bstream@v1.6.5-rc9.0.20240426031326-b8c7c4876e72/pkg/test/patch_models/applet.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/depends/kit/sqlx/builder" 10 "github.com/machinefi/w3bstream/pkg/models" 11 ) 12 13 var _targetModelApplet = reflect.TypeOf(&models.Applet{}) 14 15 func AppletFetchByAppletID(patch *gomonkey.Patches, overwrite *models.Applet, err error) *gomonkey.Patches { 16 return patch.ApplyMethod( 17 _targetModelApplet, 18 "FetchByAppletID", 19 func(receiver *models.Applet, _ sqlx.DBExecutor) error { 20 if overwrite != nil { 21 *receiver = *overwrite 22 } 23 return err 24 }, 25 ) 26 } 27 28 func AppletList(patch *gomonkey.Patches, data []models.Applet, err error) *gomonkey.Patches { 29 return patch.ApplyMethod( 30 _targetModelApplet, 31 "List", 32 func(_ *models.Applet, _ sqlx.DBExecutor, _ builder.SqlCondition, _ ...builder.Addition) ([]models.Applet, error) { 33 return data, err 34 }, 35 ) 36 }