github.com/machinefi/w3bstream@v1.6.5-rc9.0.20240426031326-b8c7c4876e72/pkg/test/patch_modules/deploy.go (about) 1 package patch_modules 2 3 import ( 4 "context" 5 6 "github.com/agiledragon/gomonkey/v2" 7 8 "github.com/machinefi/w3bstream/pkg/depends/base/types" 9 "github.com/machinefi/w3bstream/pkg/enums" 10 "github.com/machinefi/w3bstream/pkg/models" 11 "github.com/machinefi/w3bstream/pkg/modules/deploy" 12 ) 13 14 func DeployGetBySFID(patch *gomonkey.Patches, m *models.Instance, err error) *gomonkey.Patches { 15 return patch.ApplyFunc( 16 deploy.GetBySFID, 17 func(_ context.Context, _ types.SFID) (*models.Instance, error) { return m, err }, 18 ) 19 } 20 21 func DeployUpsertByCode(patch *gomonkey.Patches, m *models.Instance, err error) *gomonkey.Patches { 22 return patch.ApplyFunc( 23 deploy.UpsertByCode, 24 func(_ context.Context, _ *deploy.CreateReq, _ []byte, _ enums.InstanceState, _ ...types.SFID) (*models.Instance, error) { 25 return m, err 26 }, 27 ) 28 } 29 30 func DeployRemoveBySFID(patch *gomonkey.Patches, err error) *gomonkey.Patches { 31 return patch.ApplyFunc( 32 deploy.RemoveBySFID, 33 func(_ context.Context, _ types.SFID) error { return err }, 34 ) 35 } 36 37 func DeployGetByAppletSFID(patch *gomonkey.Patches, v *models.Instance, err error) *gomonkey.Patches { 38 return patch.ApplyFunc( 39 deploy.GetByAppletSFID, 40 func(_ context.Context, _ types.SFID) (*models.Instance, error) { return v, err }, 41 ) 42 } 43 44 func DeployListByCond(patch *gomonkey.Patches, v []models.Instance, err error) *gomonkey.Patches { 45 return patch.ApplyFunc( 46 deploy.ListByCond, 47 func(_ context.Context, _ *deploy.CondArgs) ([]models.Instance, error) { return v, err }, 48 ) 49 } 50 51 func DeployWithInstanceRuntimeContext(patch *gomonkey.Patches, ctx context.Context, err error) *gomonkey.Patches { 52 return patch.ApplyFunc( 53 deploy.WithInstanceRuntimeContext, 54 func(_ context.Context) (context.Context, error) { return ctx, err }, 55 ) 56 } 57 58 func DeployRemoveByAppletSFID(patch *gomonkey.Patches, err error) *gomonkey.Patches { 59 return patch.ApplyFunc( 60 deploy.RemoveByAppletSFID, 61 func(_ context.Context, _ types.SFID) error { return err }, 62 ) 63 }